import request from '@/router/axios';
import {
  getRouteDetail,
  checkUserCode,
  collaborativeOperation,
  getcooperatorList,
  getOperationTool,
  bindingTool,
  unbindingTool,
  bindingEquipment,
  bindingAccessories,
  getAccessoriesList,
  unbindingAccessories,
  getFailureInfoByCode,
  saveFailureInfo,
  failureEnter,
  getSnProductInfo,
  getPlmSessionId,
  getPlmEsopId,
  getPlmEsopUrl,
  checkPackNo,
  workOrderfeeding,
  getFeedingList,
  getNoKeyFeedingData,
  getLineDetail,
  checkIsFeeding,
  toolRelation,
  getToolTypeList,
  getMachineUseRecord,
  submitToolList,
  checkSkill,
  getAlreadyOnMachine,
  getViewSettingList
} from '@/api/product/station-manage';
import { focusInput, selectInput, showSuccessLog, showFailLog, showWarningLog, showVoiceLog } from '@/util/helpers';
import CommonModalTemplate from '@/components/common-modal-template/common-modal-template.vue';
import OperationLog from '@/components/operation-log/operation-log.vue';
import { resetRouter } from '@/router/router';
import { downLoad } from '@/api/resource/attach';
import website from '@/config/website';
import { getToken } from '@/util/auth';
import QRCode from 'qrcodejs2';
import Swiper from 'swiper';
import { getParamDetail } from '@/api/system/param';
import StationuiDialog from './stationui-dialog.vue';
export default {
  components: {
    CommonModalTemplate,
    OperationLog,
    StationuiDialog
  },
  data() {
    return {
      timerId: null,
      returnObject: {}, //工站信息
      stationUiList: [],
      customForms: {},
      failureInfoDic: [], //不良现象字典
      failureInfoForm: [], //不良现象
      registerInfoForm: {}, //员工编码
      registerInfoOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: '员工编码',
            prop: 'code',
            span: 8
          }
        ]
      }, //员工登记信息
      registerInfoList: [], //员工登记信息
      registerInfoListOption: {
        height: 250,
        calcHeight: 30,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        viewBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexLabel: '序号',
        editBtn: false,
        delBtn: false,
        column: [
          {
            label: '员工名称',
            prop: 'cooperatorName'
          },
          {
            label: '员工编码',
            prop: 'cooperatorCode'
          },
          {
            label: '开始时间',
            prop: 'joinTime'
          },
          {
            label: '已工作时间',
            prop: 'workingHours',
            formatter: (val) => {
              let now = new Date().getTime();
              let joinTime = new Date(val.joinTime).getTime();
              let duration = Math.abs(now - joinTime);
              let hours = Math.floor(duration / (3600 * 1000));
              let minutes = Math.floor((duration % (3600 * 1000)) / (60 * 1000));
              return `${hours} 小时 ${minutes} 分钟`;
            }
          }
        ]
      }, //员工登记信息表格配置
      isShowDialog: false, //员工登记信息模态框是否显示
      registerName: '', //员工登记名称
      tableOption: {}, //公共模态框配置
      modalName: '', //公共模态框名称
      userInfo: {}, //用户信息
      timer: '',
      isRequestComplete: true, //是否请求完成,
      isShowSuccessMsg: true, //是否显示成功提示
      successMsgList: [], //所有操作类成功提示
      showEsopDialog: false,
      esopType: '',
      pdfUrl: '',
      showPackWeightDialog: false, //是否显示包装称重
      packWeightInfo: {}, //包装称重信息
      httpRequestParams: {}, //包装称重时暂存api配置
      commonDataList: [], //包装称重时暂存手动封箱按钮api配置
      isAutomatic: true, //区别是否自动封箱
      attributeCopyIndex: 0, //多不良代码下标
      openModalInputName: '', //打开数据选择框的输入框name
      showEquipmentRegisterDialog: false, //设备登记是否显示
      equipmentForm: {},
      equipmentOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 115,
        column: [
          {
            label: '设备编码',
            prop: 'equipmentCode',
            span: 10,
            rules: [
              {
                required: true,
                message: '请输入设备编码',
                trigger: 'blur'
              }
            ]
          }
        ]
      },
      equipmentList: [], //已登记设备信息
      equipmentListOption: {
        //已登记设备信息表格配置
        height: 350,
        calcHeight: 30,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexLabel: '序号',
        column: [
          {
            label: '设备编码',
            prop: 'toolCode'
          },
          {
            label: '设备名称',
            prop: 'toolName'
          }
        ]
      },
      showToolRegisterDialog: false, //工装治具登记是否显示
      toolOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 115,
        column: [
          {
            label: '工装治具编码',
            prop: 'toolCode',
            span: 10,
            rules: [
              {
                required: true,
                message: '请输入工装治具编码',
                trigger: 'blur'
              }
            ]
          }
        ]
      },
      toolForm: {},
      toolList: [], //已登记工装治具信息
      toolListOption: {
        //已登记工装治具表格配置
        height: 350,
        calcHeight: 30,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexLabel: '序号',
        column: [
          {
            label: '工具编码',
            prop: 'toolCode'
          },
          {
            label: '工具规格',
            prop: 'toolSpec'
          }
        ]
      },
      isShowFunctionBox: false,
      autoDeductionFinishedQuantity: 0, //用来自动扣减的合格数
      showAccessoriesRegisterDialog: false, //是否显示辅料登记模态框
      accessoriesForm: {}, //辅料登记信息
      accessoriesOption: {
        //辅料登记配置信息
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: '辅料类型',
            prop: 'accessoriesType',
            span: 10,
            type: 'select',
            dicData: [
              {
                label: '胶水',
                value: 'GLUE_BARCODE'
              }
            ],
            rules: [
              {
                required: true,
                message: '请选择辅料类型',
                trigger: 'blur'
              }
            ],
            change: (val) => {
              this.accessoriesForm.accessoriesType = val.value;
              if (this.accessoriesForm.accessoriesType) {
                this.getAccessoriesList();
              }
            }
          },
          {
            label: '辅料条码',
            prop: 'accessoriesCode',
            span: 10,
            rules: [
              {
                required: true,
                message: '请输入辅料条码',
                trigger: 'blur'
              }
            ]
          }
        ]
      },
      accessoriesList: [], //已登记辅料信息
      accessoriesListOption: {
        //已登记辅料信息表格配置
        height: 350,
        calcHeight: 30,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexLabel: '序号',
        column: [
          {
            label: '辅料条码',
            prop: 'toolCode'
          },
          {
            label: '状态',
            prop: 'partIndirectStatus',
            type: 'select',
            dicData: []
          }
        ]
      },
      expiredQuantity: 0,
      multiplePrintIndex: 0, //打印多标签打印机选择下标
      multipleLabelTemplateIndex: 0, //打印多标签标签模板选择下标
      extraPrint: [], //多标签打印打印机打印模版集合
      fileUploadBox: false, //附件上传模态框是否显示
      fileList: [], //附件列表
      isCheckExpireMes: false, //是否校验辅料达到使用时长或过期提示
      inProgressField: '', //请求进行中的字段名称
      showStationFeedingInfoDialog: false,
      showFailureRegisterDialog: false,
      failureRegisterForm: {},
      failureRegisterOption: {
        submitBtn: false,
        submitText: '录入',
        emptyBtn: false,
        labelWidth: 125,
        column: [
          {
            label: '工单号',
            prop: 'workOrderNo',
            disabled: true
          },
          {
            label: '产品序列号',
            prop: 'productSequenceNumber'
          },
          {
            label: '产品编码',
            prop: 'productPartNo',
            disabled: true
          },
          {
            label: '产品名称',
            prop: 'productPartName',
            disabled: true
          },
          {
            label: '产品型号',
            prop: 'productPartModel',
            disabled: true
          },
          {
            label: '不良数',
            prop: 'quantity',
            type: 'number',
            disabled: false,
            minRows: 0,
            span: 12,
            rules: [
              {
                required: true,
                message: '请输入不良数',
                trigger: 'blur'
              },
              {
                required: true,
                trigger: 'blur',
                validator: (rule, value, callback) => {
                  let reg = /^\+?[1-9]\d*$/;
                  if (!reg.test(value)) {
                    callback(new Error('只能输入正整数'));
                  } else {
                    callback();
                  }
                }
              }
            ]
          },
          {
            label: '不良数',
            prop: 'quantity',
            type: 'number',
            precision: 0,
            minRows: 1,
            row: true,
            display: false,
            rules: [
              {
                required: true,
                message: '请输入不良数',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '登记产线',
            prop: 'lineName',
            disabled: true
          },
          {
            label: '登记工序',
            prop: 'fromRouteName',
            disabled: true
          },

          {
            label: '登记工位',
            prop: 'stationName',
            disabled: true
          },
          {
            label: '不良现象代码',
            prop: 'failureCode',
            type: 'select',
            dicData: [],
            rules: [
              {
                required: true,
                trigger: 'blur',
                validator: (rule, value, callback) => {
                  if (this.failureInfoForm.length <= 0) {
                    callback(new Error('请输入不良代码或者扫描代码'));
                  } else {
                    callback();
                  }
                }
              }
            ]
          },
          {
            label: '不良现象',
            prop: 'failureInfo',
            // span: 24,
            type: 'textarea',
            maxRows: 3,
            minRows: 3,
            disabled: true,
            rules: [
              {
                required: true,
                message: '请输入不良现象',
                trigger: 'blur'
              }
            ]
          },
          // {
          //   label: '不良类型',
          //   prop: 'failureTypeName',
          //   disabled: true
          // },
          {
            label: '登记人员',
            prop: 'registryByName',
            type: 'search',
            disabled: true,
            appendClick: () => {
              this.openUserInfoCommonModal();
            }
          },

          {
            label: '登记说明',
            prop: 'remark',
            type: 'textarea',
            row: true,
            span: 24,
            maxRows: 3,
            minRows: 3
          }
        ]
      },
      failureRegisterList: [],
      failureRegisterListOption: {
        height: 350,
        calcHeight: 30,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexLabel: '序号',
        menuWidth: 150,
        column: [
          {
            label: '序列号',
            prop: 'productSequenceNumber',
            hide: false
          },
          {
            label: '工单号',
            prop: 'workOrderNo',
            hide: true
          },
          {
            label: '不良登记工序',
            prop: 'fromRouteName'
          },
          {
            label: '不良现象',
            prop: 'failureName'
          },
          {
            label: '不良数',
            prop: 'quantity'
          },
          {
            label: '不良登记说明',
            prop: 'remark'
            // hide: true
          }
        ]
      },
      failureCodeList: [],
      failureNameList: [],
      showMixPackDialog: false, //混包模态框是否显示
      mixPackForm: {},
      mixPackOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 100,
        column: [
          {
            label: '包装数量',
            prop: 'standardQuantity',
            disabled: true
          },
          {
            label: '产品序列号',
            prop: 'mixPackSequenceNumber',
            display: true,
            rules: [
              {
                required: true,
                message: '请输入产品序列号',
                trigger: 'submit'
              }
            ]
          }
        ]
      },
      productInfoOption: {
        height: 350,
        calcHeight: 30,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexLabel: '序号',
        menuWidth: 150,
        column: [
          {
            label: '产品序列号',
            prop: 'sequenceNumber'
          },
          {
            label: '工单号',
            prop: 'workOrderNo'
          },
          {
            label: '产品编码',
            prop: 'partNo'
          }
        ]
      },
      mixPackProductList: [],
      mixPackField: '', //混包关联表格字段
      beforeRequestData: [],
      showBeforeRequestDialog: false,
      beforeRequestRules: {},
      isDefaultHide: true,
      sequenceNumberRepeat: false, //产品序列号与待提交序列号是否重复
      isGetEsopByPlm: false, //是否获取PLM的ESOP
      loading: false,
      setIntervalList: [], //定时调用变量的声明集合
      mixPackHttpRequestList: [],
      multiplePrinterInfo: [],
      showWorkOrderFeedingDialog: false,
      workOrderFeedingForm: {},
      workOrderFeedingOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 130,
        column: [
          {
            label: '工单号',
            prop: 'workOrderNo',
            disabled: true
          },
          {
            label: '上料产线',
            prop: 'lineName',
            disabled: true
          },
          {
            label: '上料工段',
            prop: 'sectionName',
            disabled: true
          },
          {
            label: '原材料包装条码',
            prop: 'packNo',
            rules: [
              {
                required: true,
                message: '请输入原材料包装条码',
                trigger: 'submit'
              }
            ]
          }
        ]
      },
      feedingInfoData: [],
      feedingInfoOption: {
        height: 250,
        calcHeight: 30,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexLabel: '序号',
        menu: false,
        column: [
          {
            label: '物料编码',
            prop: 'partNo'
          },
          {
            label: '物料名称',
            prop: 'partName'
          },
          {
            label: '物料型号',
            prop: 'partModel'
          },
          {
            label: '上料工段',
            prop: 'workSectionName'
          },
          {
            label: '需求数量',
            prop: 'workOrderRequireQuantity'
          },
          {
            label: '已上数量',
            prop: 'feedingQuantity'
          },
          {
            label: '已用数量',
            prop: 'usedQuantity'
          }
        ]
      },
      feedingDetailInfoData: [],
      feedingDetailInfoOption: {
        height: 250,
        calcHeight: 30,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexLabel: '序号',
        menu: false,
        column: [
          {
            label: '原材料包装条码',
            prop: 'packNo'
          },
          {
            label: '包装数量',
            prop: 'quantity'
          },
          {
            label: '物料编码',
            prop: 'partNo'
          },
          {
            label: '物料型号',
            prop: 'partModel'
          },
          {
            label: '上料产线',
            prop: 'lineName'
          },
          {
            label: '上料人',
            prop: 'onlineFeedBy'
          }
        ]
      },
      showToolOperateDialog: false,
      toolOperateForm: {},
      toolOperateOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 100,
        column: [
          {
            label: '工单号',
            prop: 'workOrderNo',
            disabled: true
          },
          {
            label: '产品编码',
            prop: 'partNo',
            disabled: true
          },
          {
            label: '产品名称',
            prop: 'partName',
            disabled: true
          },
          {
            label: '工单数量',
            prop: 'planQuantity',
            disabled: true
          },
          {
            label: '设备编码',
            prop: 'machineCode',
            rules: [
              {
                required: true,
                message: '请输入设备编码',
                trigger: 'submit'
              }
            ]
          },
          {
            label: '工具类型',
            prop: 'toolType',
            type: 'select',
            dicData: [],
            rules: [
              {
                required: true,
                message: '请选择工具类型',
                trigger: 'submit'
              }
            ]
          },
          {
            label: '穴数',
            prop: 'numberCavities',
            disabled: true,
            display: false
          },
          {
            label: '工具编码',
            prop: 'toolCode',
            rules: [
              {
                required: true,
                message: '请选择工具类型',
                trigger: 'submit'
              }
            ]
          }
        ]
      },
      toolOperateInfoData: [],
      toolOperateInfoOption: {
        height: 250,
        calcHeight: 30,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexLabel: '序号',
        menu: true,
        column: [
          {
            label: '工具类型',
            prop: 'toolType',
            type: 'select',
            dicData: []
          },
          {
            label: '工具编码',
            prop: 'toolCode'
          },
          {
            label: '规格',
            prop: 'equipmentSpecification'
          },
          {
            label: '最大使用次数',
            prop: 'maxUsage'
          },
          {
            label: '剩余使用次数',
            prop: 'surplusUsage'
          }
        ]
      },
      toolsType: [],
      toolTypeList: [],
      showToolDetailDialog: false,
      toolDetailForm: {},
      toolDetailOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 125,
        column: []
      },
      toolIsUseRecord: false,
      noFeedingPromptNum: 0,
      statiouiDialogConfig: {},
      showDialogUi: false,
      showOrHideObj: {
        equipmentRegister: true,
        toolRegister: true,
        accessoriesRegister: true,
        badRegister: true,
        workOrderFeeding: true,
        toolOperation: true
      }
    };
  },
  computed: {
    headersObj() {
      let header = { Authorization: `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}` };
      header['Blade-Auth'] = 'bearer ' + getToken();
      return header;
    }
  },
  mounted() {
    let themeName = this.$store.state.common.themeName;
    document.body.className = themeName;
    if (JSON.stringify(this.$store.state.stationOperation.workStationInfo) === '{}') {
      this.returnObject = JSON.parse(localStorage.getItem('workStationInfo'));
    } else {
      this.returnObject = JSON.parse(JSON.stringify(this.$store.state.stationOperation.workStationInfo));
    }
    this.returnObject['siteId'] = localStorage.getItem('saber-siteId');
    this.returnObject['tenantId'] = JSON.parse(localStorage.getItem('saber-tenantId')).content;
    this.returnObject['token'] = 'bearer ' + getToken();
    // if (this.returnObject.workorderStationId) {
    //   this.getRegisterInfoList();
    // }
    this.findStationInfo(this.returnObject.workOrderId, this.returnObject.workStationCode);
    this.userInfo = JSON.parse(localStorage.getItem('saber-userInfo'));
    // this.getBindAccessoriesList();
    this.returnObject['isSupportMixPack'] = false;
    //判断ESOP是否从平野PLM中获取
    getParamDetail({
      paramKey: 'qms.plm_inpectionTemplate_config'
    }).then((res) => {
      let data = res.data.data;
      this.isGetEsopByPlm = this._get(data, 'paramValue') === 'true' ? true : false;
    });
    //根据参数管理判断工站作业是否管控工单上料和工具上机
    this.checkWorkOrderFeeding();
    // getViewSettingList('stationOpTemplate').then((res) => {
    //   let data = this._get(res, 'data.data', []);
    //   this._forEach(data, (item) => {
    //     this.showOrHideObj[item.code] = item.status == 1 ? true : false;
    //   });
    // });
  },
  beforeDestroy() {
    this.$store.commit('stationOperation/setworkStationInfo', {});
    this._forEach(this.setIntervalList, (item) => {
      clearInterval(window[item]);
    });
  },
  watch: {
    'failureRegisterForm.productSequenceNumber'(value) {
      let quantity = this.findObject(this.failureRegisterOption.column, 'quantity');
      if (value) {
        quantity.disabled = true;
        this.failureRegisterForm.quantity = 1;
      } else {
        quantity.disabled = false;
      }
    }
  },
  methods: {
    /**
     * 查询工站信息
     * @param stationId
     */
    findStationInfo(workOrderId, stationCode) {
      getRouteDetail(workOrderId, stationCode).then((res) => {
        // this.model.stationName = this._get(res, 'data.data.name', '');
        // this.returnObject.stationName = this._get(res, 'data.data.name', '');
        this.returnObject.stationType = this._get(res, 'data.data.routeType', '');
        let uiPage = this._get(res, 'data.data.uiPage', '');
        console.log(uiPage);
        if (!uiPage) {
          this.$message({
            type: 'warning',
            message: '工站未进行UI设计，请联系管理员！'
          });
          showFailLog('工站未进行UI设计，请联系管理员！');
          return;
        }
        let uiJson = this._get(res, 'data.data.uiJson', '');
        if (!uiJson) {
          this.$message({
            type: 'warning',
            message: '工站UI设计数据源错误，请联系管理员！'
          });
          showFailLog('工站UI设计数据源错误，请联系管理员！');
          return;
        }
        this.stationUiList = uiJson ? JSON.parse(uiJson) : [];
        console.log(this.stationUiList);

        this.customForms = this.refactoringDynamicFormData(this.stationUiList);

        $('.opration-div').empty();
        $('.opration-div').append(uiPage);
        $('.opration-div').find('.table-dark tbody').empty();
        $('.opration-div')
          .find('.table-report td')
          .each((index, item) => {
            let inputVal = $(item).find('.input-control').val();
            if ($(item).find('.input-control') && inputVal) {
              $(item).html(inputVal);
            }
          });

        console.log(this.customForms);
        this._forEach(this.customForms, (item) => {
          let $dragItem = $(`#${item.key}`);
          //赋值默认值
          if (item.defaultValue) {
            if (item.dataType === 'radio') {
              let dataSource = this._get(item, 'dataSource', []);
              let valueObj = this._find(dataSource, { key: item.defaultValue });
              let defaultValue = this._get(dataSource, '[0].key', '');
              if (valueObj) {
                $dragItem.find('input[value=' + item.defaultValue + ']').prop('checked', true);
              } else {
                $dragItem.find('input[value=' + defaultValue + ']').prop('checked', true);
              }
            } else if (item.dataType === 'select') {
              // let dataSource = this._get(item, 'dataSource', []);
              // //下拉框赋默认值
              // let valueObj = this._find(dataSource, { optionField: item.defaultValue });
              // if (valueObj) {
              //   $dragItem.find('select').val(item.defaultValue);
              // } else {
              //   let defaultValue = this._get(dataSource, '[0].optionField', '');
              //   $dragItem.find('select').val(defaultValue);
              // }
              // this.returnObject[item.field] = item.defaultValue;
            } else {
              $dragItem.find('input').val(item.defaultValue);
              this.returnObject[item.field] = item.defaultValue;
            }
          }

          if (item.dataType === 'info-input') {
            if (item.field === 'shiftName') {
              this.setFormValue('shiftName', this.returnObject.shiftName);
            }
            if (item.field === 'standardQuantity' && this.returnObject.isCarrier) {
              $dragItem.find('input[name=' + item.field + ']').prop('disabled', false);
              let regexp = /^[1-9]\d*$/;
              $('#' + item.key)
                .find('[name=' + item.field + ']')[0]
                .addEventListener('keyup', (event) => {
                  // 通过正则表达式验证字符
                  // 超时调用
                  // setTimeout(() => {
                  let result = event.target.value;
                  if (regexp.test(result)) {
                    this.returnObject[item.field] = result;
                  } else {
                    this.returnObject[item.field] = '';
                    this.setFormValue(item.field, '');
                  }
                });
            }
            if (item.field === 'externalSequenceDefinitionName' && this.returnObject.isBindExternalSn) {
              this.setFormValue('externalSequenceDefinitionName', this.returnObject.externalSequenceDefinitionName);
            }
          }

          //绑定keyup事件，实时将用户输入的值保存至returnObject中
          if (item.dataType === 'input') {
            $('#' + item.key)
              .find('[name=' + item.field + ']')[0]
              .addEventListener('keyup', (event) => {
                // 通过正则表达式验证字符
                if (item.regexp) {
                  // 超时调用
                  setTimeout(() => {
                    let result = event.target.value;
                    if (result) {
                      result = this._trim(result);
                      this.returnObject[item.field] = '';
                      this.returnObject[item.field] = result;

                      this.setFormValue(item.field, '');
                      this.setFormValue(item.field, result);
                    }
                  }, 80);
                } else {
                  this.returnObject[item.field] = event.target.value;
                }
              });
            if (this.returnObject.isAutomaticAcquisition && item.field === 'sequenceNumber') {
              $dragItem.find('input[name=' + item.field + ']').prop('disabled', true);
            }
            // if (this.returnObject.isBindExternalSn && item.field === 'extendSequenceNumber') {
            //   item.isRequired = 'true';
            //   let isRequired = $dragItem.find('label').hasClass('required');
            //   if (!isRequired) {
            //     $dragItem.find('.drag-item-text').prepend(`<span class="required text-danger">*</span>`);
            //   }
            // } else if (!this.returnObject.isBindExternalSn && item.field === 'extendSequenceNumber') {
            //   item.isRequired = false;
            //   $dragItem.find('input[name=' + item.field + ']').prop('disabled', true);
            // }
          }

          if (item.dataType === 'input-checkbox') {
            let $input = $('#' + item.key).find('[name=' + item.field + ']')[0];
            $input.addEventListener('keyup', (event) => {
              this.returnObject[item.field] = event.target.value;
            });
            let checkbox = $($input).next()[0];
            checkbox.addEventListener('click', (event) => {
              if ($($input).prop('disabled')) {
                $($input).prop('disabled', false);
                item.isRequired = 'true';
                let isRequired = $dragItem.find('label').hasClass('required');
                if (!isRequired) {
                  $dragItem.find('.drag-item-text').prepend(`<span class="required text-danger">*</span>`);
                }
              } else {
                item.isRequired = false;
                $dragItem.find('label .required').remove();
                $($input).prop('disabled', true);
                this.returnObject[item.field] = '';
                this.setFormValue(item.field, '');
              }
            });
          }

          if (item.dataType === 'table') {
            let tableCacheInfo = localStorage.getItem(`${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}`);
            if (tableCacheInfo) {
              let key = JSON.parse(tableCacheInfo).key;
              this.returnObject[key.field] = JSON.parse(tableCacheInfo).tableList;
              this.setTableValue(key, JSON.parse(tableCacheInfo).tableList);
            }
          }

          //为载具赋值载具类型
          if (item.dataType === 'vehicle') {
            $('#' + item.key)
              .find('[name=' + item.field + ']')[0]
              .addEventListener('keyup', (event) => {
                // 通过正则表达式验证字符
                if (item.regexp) {
                  // 超时调用
                  setTimeout(() => {
                    let result = event.target.value;
                    if (result) {
                      result = this._trim(result);
                      this.returnObject[item.field] = '';
                      this.returnObject[item.field] = result;

                      this.setFormValue(item.field, '');
                      this.setFormValue(item.field, result);
                    }
                  }, 80);
                } else {
                  this.returnObject[item.field] = event.target.value;
                }
              });
            if (item.vehicleTypeField) {
              this.returnObject[item.vehicleTypeField] = item.vehicleType;
            } else {
              this.returnObject['carrierType'] = item.vehicleType;
            }
          }
          if (item.dataType === 'attribute-copy') {
            let selectFailureCode = $($('#attributeCopy').find('.failureCode')[0]).find('input').next('.el-input-group__append')[0];
            selectFailureCode.addEventListener('click', (event) => {
              this.openAttributeCopyFailureModal(0);
            });
            let button = $('#attributeCopy').find('.attributeCopyBtn button')[0];
            button.addEventListener('click', (event) => {
              $('#attributeCopy').find('.attributeCopyBtn').before(`<div class="failureCode">
                  <label><span class="drag-item-text">不良现象代码</span>：</label>
                  <div class="el-input el-input--small el-input-group el-input-group--append el-input--suffix avue-input">
                      <input class="el-input__inner" type="text" name="failureCode" placeholder="请输入不良现象代码">
                      <div class="el-input-group__append">
                          <button type="button" class="el-button el-button--default el-button--small"><i class="el-icon-search"></i></button>
                      </div>
                  </div>
              </div>
              <div class="unqualifiedQuantity">
                  <label><span class="drag-item-text">数量</span>：</label>
                  <input class="el-input__inner" type="number" name="unqualifiedQuantity" autocomplete="off" placeholder="请输入数量">
              </div>`);
              //多不良现象组件如果开启了自动扣减合格数，则添加不良数量键入事件
              this.autoDeduction(item);
              this._forEach($('#attributeCopy').find('.failureCode'), (item, index) => {
                $(item)
                  .find('label span')
                  .text(`不良现象代码${index + 1}`);
                selectFailureCode = $(item).find('input').next('.el-input-group__append')[0];
                selectFailureCode.addEventListener('click', (event) => {
                  this.openAttributeCopyFailureModal(index);
                });
              });
            });
            //多不良现象组件如果开启了自动扣减合格数，则添加不良数量键入事件
            this.autoDeduction(item);
          }
          if (item.dataType === 'printers') {
            let printInfo = localStorage.getItem(`${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}_printers`);
            if (printInfo) {
              this.returnObject[item.field] = JSON.parse(printInfo).printId;
              this.setFormValue(item.field, JSON.parse(printInfo).printName);
            }
          }
          if (item.dataType === 'print-label') {
            let labelTemplateInfo = localStorage.getItem(`${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}_labelTemplate`);
            if (labelTemplateInfo) {
              this.returnObject[item.field] = JSON.parse(labelTemplateInfo).labelTemplateId;
              this.setFormValue(item.field, JSON.parse(labelTemplateInfo).labelTemplateName);
            }
          }
          //打印扩展组件添加按钮新增事件
          if (item.dataType === 'multiple-print') {
            let multiplePrinterInfo = localStorage.getItem(
              `${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}_multiplePrinterInfo`
            );
            if (!item.isCachePrintInfo) {
              console.log(multiplePrinterInfo);
              multiplePrinterInfo = '[]';
              localStorage.removeItem(`${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}_multiplePrinterInfo`);
            }
            if (multiplePrinterInfo && JSON.parse(multiplePrinterInfo).length > 0) {
              let multiplePrinterList = JSON.parse(multiplePrinterInfo);
              this.multiplePrinterInfo = multiplePrinterList;
              this._forEach(multiplePrinterList, (item, index) => {
                if (this.extraPrint[index]) {
                  this.extraPrint[index].printId = item.printId;
                  this.extraPrint[index].labelTemplateId = item.labelTemplateId;
                } else {
                  this.extraPrint.push({ printId: item.printId, labelTemplateId: item.labelTemplateId });
                }
                $($('#multiplePrint').find('.print')[index]).find('input').val(item.printName);
                $($('#multiplePrint').find('.labelTemplate')[index]).find('input').val(item.labelTemplateName);
              });
            }
            let selectPrinter = $($('#multiplePrint').find('.print')[0]).find('input').next('.el-input-group__append')[0];
            selectPrinter.addEventListener('click', (event) => {
              this.openMultiplePrinterModal(0);
            });
            let selectLabelTemplate = $($('#multiplePrint').find('.labelTemplate')[0]).find('input').next('.el-input-group__append')[0];
            selectLabelTemplate.addEventListener('click', (event) => {
              this.openMultipleLabelTemplateModal(0);
            });
            let button = $('#multiplePrint').find('.multiplePrintBtn button')[0];
            button.addEventListener('click', (event) => {
              $('#multiplePrint').find('.multiplePrintBtn').before(`<div class="labelTemplate">
                  <label><span class="drag-item-text">标签模板</span>：</label>
                  <div class="el-input el-input--small el-input-group el-input-group--append el-input--suffix avue-input">
                      <input class="el-input__inner" type="text" disabled placeholder="请选择标签模板">
                      <div class="el-input-group__append">
                          <button type="button" class="el-button el-button--default el-button--small"><i class="el-icon-search"></i></button>
                      </div>
                  </div>
              </div>
              <div class="print">
                  <label><span class="drag-item-text">打印机</span>：</label>
                  <div class="el-input el-input--small el-input-group el-input-group--append el-input--suffix avue-input">
                      <input class="el-input__inner" type="text" disabled placeholder="请选择打印机">
                      <div class="el-input-group__append">
                          <button type="button" class="el-button el-button--default el-button--small"><i class="el-icon-search"></i></button>
                      </div>
                  </div>
              </div>`);
              this._forEach($('#multiplePrint').find('.print'), (item, index) => {
                $(item)
                  .find('label span')
                  .text(`打印机${index + 1}`);
                selectPrinter = $(item).find('input').next('.el-input-group__append')[0];
                selectPrinter.addEventListener('click', (event) => {
                  this.openMultiplePrinterModal(index);
                });
              });
              this._forEach($('#multiplePrint').find('.labelTemplate'), (item, index) => {
                $(item)
                  .find('label span')
                  .text(`标签模版${index + 1}`);
                selectLabelTemplate = $(item).find('input').next('.el-input-group__append')[0];
                selectLabelTemplate.addEventListener('click', (event) => {
                  this.openMultipleLabelTemplateModal(index);
                });
              });
            });
          }
          //兼容多个同类型数据选择框
          if (
            (item.dataType === 'select-data' && item.selectDataType) ||
            (item.dataType === 'printers' && item.selectDataType) ||
            (item.dataType === 'print-label' && item.selectDataType)
          ) {
            if (item.defaultSelectDataCode) {
              this.returnObject[item.field] = this._get(item, 'defaultSelectDataCode', '');
              this.setFormValue(item.field, this._get(item, 'defaultSelectDataName', ''));
            }
            let selectDataIcon = $('[name=' + item.field + ']').next('.el-input-group__append')[0];
            if (selectDataIcon) {
              selectDataIcon.addEventListener('click', (event) => {
                this.openModalInputName = item.field;
                switch (item.selectDataType) {
                  case 'failure':
                    //打开选择不良现象组件框
                    this.openFailureModal();
                    break;
                  case 'standardQuantity':
                    //打开选择包规数量组件框
                    this.openPackTypeModal();
                    break;
                  case 'print':
                    //打开选择打印机组件
                    this.openPrinterModal();
                    break;
                  case 'labelTemplate':
                    // 打开选择打印模板组件
                    this.openLabelTemplateModal();
                    break;
                  case 'sequenceDefine':
                    // 打开选择序列号规则
                    this.openSequenceDefineModal();
                    break;
                  case 'maintenanceCode':
                    // 打开选择维修代码
                    this.openMaintenanceCodeModal();
                    break;
                  default:
                    break;
                }
              });
            }
          }
          //附件上传
          if (item.dataType === 'file-button') {
            let fileBtn = $('.fileBtn').find('.el-button')[0];
            if (fileBtn) {
              fileBtn.addEventListener('click', (event) => {
                this.fileUploadBox = true;
                if (this.fileList.length === 0) {
                  this.$nextTick(() => {
                    this.$refs.fileUpload.clearFiles();
                  });
                }
              });
            }
          }
          if (item.dataType === 'info-input' && item.isLocalStorage) {
            let val = localStorage.getItem(item.field + this.returnObject.workorderStationId);
            this.returnObject[item.field] = val;
            this.setFormValue(item.field, val);
          }
          if (item.dataType === 'qrcode') {
            $('#qrCode').empty();
            this.$nextTick(() => {
              new QRCode('qrCode', {
                text: this.returnObject[item.createQrCode],
                width: 100,
                height: 100,
                colorDark: '#000000',
                colorLight: '#ffffff',
                correctlevel: QRCode.CorrectLevel.H
              });
            });
          }
          if (item.dataType === 'border-title') {
            if (item.isHideModule) {
              let parent = $(`#${item.key}`).parent();
              $(parent).css('display', 'none');
            }
          }
          if (item.dataType === 'select') {
            $($('#' + item.key).find('[name=' + item.field + ']')[0]).css({
              width: '62%',
              'border-color': '#dcdfe6',
              'border-radius': '4px',
              padding: '0px 12px',
              color: '#606266'
            });
            $($('#' + item.key).find('[name=' + item.field + ']')[0]).empty();
            if (item.optionListApi) {
              let parameterDatas = [];
              let dataSourceRequestParam = [];
              dataSourceRequestParam = item.dataSourceRequestParam.split(',');
              this._forEach(dataSourceRequestParam, (item) => {
                parameterDatas.push({ code: item, value: this.returnObject[item] });
              });
              let params = {
                apiCode: item.optionListApiCode,
                parameterDatas: parameterDatas
              };
              request({
                url: encodeURI(item.optionListApi),
                method: 'post',
                data: params
              }).then((res) => {
                let optionList = this._get(res, 'data.data', []);
                $($('#' + item.key).find('[name=' + item.field + ']')[0]).append('<option value="">请选择</option>');
                this._forEach(optionList, (optionItem) => {
                  if (item.dataSourceFormat) {
                    let format = item.dataSourceFormat.split('-');
                    $($('#' + item.key).find('[name=' + item.field + ']')[0]).append(`<option value=${optionItem[format[1]]}>${optionItem[format[0]]}</option>`);
                  } else {
                    $($('#' + item.key).find('[name=' + item.field + ']')[0]).append(`<option value=${optionItem.value}>${optionItem.key}</option>`);
                  }
                });
              });
            }
          }
          if (item.dataType === 'extended-fields') {
            this._forEach(item.options, (optionsItem) => {
              if (optionsItem.type === 'select') {
                $($('#' + item.key).find('[name=' + optionsItem.field + ']')[0]).css({
                  width: '62%',
                  'border-color': '#dcdfe6',
                  'border-radius': '4px',
                  padding: '0px 12px',
                  color: '#606266'
                });
                $($('#' + item.key).find('[name=' + optionsItem.field + ']')[0]).empty();
                if (optionsItem.dataSource) {
                  request({
                    url: encodeURI(optionsItem.dataSource),
                    method: 'get'
                  }).then((res) => {
                    let optionList = this._get(res, 'data.data', []);
                    $($('#' + item.key).find('[name=' + optionsItem.field + ']')[0]).append('<option value="">请选择</option>');
                    this._forEach(optionList, (optionItem) => {
                      $($('#' + item.key).find('[name=' + optionsItem.field + ']')[0]).append(`<option value=${optionItem.dictKey}>${optionItem.dictValue}</option>`);
                    });
                  });
                }
              }
            });
          }
          console.log(item.dataType);
          if (item.dataType === 'hidebtn') {
            let parent1 = $('#' + item.key).parent();
            let parent2 = $($(parent1)[0]).parent();
            $($(parent2)[0]).css({ 'margin-bottom': '0', 'margin-top': '-16px' });
            if (item.isDefaultHide) {
              this.isDefaultHide = false;
              this._forEach(item.hideFormItemList, (hideItem) => {
                let ele = $('[name=' + hideItem + ']').parent();
                $($(ele)[0]).css('display', 'none');
              });
            }
            let hideBtn = $('.hideBtn').find('.el-button')[0];
            if (hideBtn) {
              hideBtn.addEventListener('click', (event) => {
                if (this.isDefaultHide) {
                  this._forEach(item.hideFormItemList, (hideItem) => {
                    let ele = $('[name=' + hideItem + ']').parent();
                    $($(ele)[0]).css('display', 'none');
                  });
                  this.isDefaultHide = false;
                } else {
                  this._forEach(item.hideFormItemList, (hideItem) => {
                    let ele = $('[name=' + hideItem + ']').parent();
                    $($(ele)[0]).css('display', 'block');
                  });
                  this.isDefaultHide = true;
                }
              });
            }
          }
          if (item.dataType === 'chart') {
            $($('#' + item.key))
              .find('.swiper-wrapper')
              .empty();
            setTimeout(() => {
              let chartContent = $('#' + item.key).find('.swiper');
              let chartContentWidth = chartContent.outerWidth();
              // chartContent.css({ 'width': chartContentWidth, 'height': item.chartHeight });
              this._forEach(item.chartSourceList, (chartSourceItem, index) => {
                let url = chartSourceItem.url;
                this._forEach(chartSourceItem.params, (paramItem, paramIndex) => {
                  if (paramIndex === 0) {
                    if (!paramItem.mapingCode) {
                      if (paramItem.defaultValue) {
                        url = url + `?${paramItem.code}=${paramItem.defaultValue}`;
                      } else {
                        url = url + `?${paramItem.code}=${this.returnObject[paramItem.code]}`;
                      }
                    } else {
                      if (paramItem.defaultValue) {
                        url = url + `?${paramItem.code}=${paramItem.defaultValue}`;
                      } else {
                        url = url + `?${paramItem.code}=${this.returnObject[paramItem.mapingCode]}`;
                      }
                    }
                  } else {
                    if (!paramItem.mapingCode) {
                      if (paramItem.defaultValue) {
                        url = url + `&${paramItem.code}=${paramItem.defaultValue}`;
                      } else {
                        url = url + `&${paramItem.code}=${this.returnObject[paramItem.code]}`;
                      }
                    } else {
                      if (paramItem.defaultValue) {
                        url = url + `&${paramItem.code}=${paramItem.defaultValue}`;
                      } else {
                        url = url + `&${paramItem.code}=${this.returnObject[paramItem.mapingCode]}`;
                      }
                    }
                  }
                });
                $($('#' + item.key)).find('.swiper-wrapper').append(`
                    <div class="swiper-slide"><iframe style="border:none; width: ${chartContentWidth}px; height: ${item.chartHeight}px;" src="${url}" class="iframe"></iframe></div>
                  `);
              });

              var mySwiper = new Swiper('.swiper', {
                direction: 'horizontal', // 垂直切换选项
                loop: item.chartSourceList.length > 1 ? true : false, // 循环模式选项

                // 如果需要分页器
                pagination: {
                  el: '.swiper-pagination'
                },

                // 如果需要前进后退按钮
                navigation: {
                  nextEl: '.swiper-button-next',
                  prevEl: '.swiper-button-prev'
                },

                autoplay: {
                  delay: 7000 //1秒切换一次
                },
                touchStartPreventDefault: false
              });
            }, 2000);
          }
          if (item.dataType === 'table') {
            let tableCacheInfo = localStorage.getItem(`${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}`);
            if (tableCacheInfo) {
              let key = JSON.parse(tableCacheInfo).key;
              this.returnObject[key.field] = JSON.parse(tableCacheInfo).tableList;
              this.setTableValue(key, JSON.parse(tableCacheInfo).tableList);
            }
          }
        });

        //定义选择数据源数据源Name值
        let modalInputNameList = ['failureCode', 'standardQuantity', 'printId', 'labelTemplateId', 'sequenceDefineId'];
        this._forEach(modalInputNameList, (name) => {
          let inputObj = this._find(this.customForms, { field: name });
          if (inputObj && !inputObj.selectDataType) {
            let selectDataIcon = $('[name=' + name + ']').next('.el-input-group__append')[0];
            if (selectDataIcon) {
              selectDataIcon.addEventListener('click', (event) => {
                this.openModalInputName = name;
                switch (name) {
                  case 'failureCode':
                    //打开选择不良现象组件框
                    this.openFailureModal();
                    break;
                  case 'standardQuantity':
                    //打开选择包规数量组件框
                    this.openPackTypeModal();
                    break;
                  case 'printId':
                    //打开选择打印机组件
                    this.openPrinterModal();
                    break;
                  case 'labelTemplateId':
                    // 打开选择打印模板组件
                    this.openLabelTemplateModal();
                    break;
                  case 'sequenceDefineId':
                    // 打开选择序列号规则
                    this.openSequenceDefineModal();
                    break;
                  default:
                    break;
                }
              });
            }
          }
        });

        let fileInputObj = this._find(this.customForms, (item) => {
          return item.field.indexOf('Url') !== -1;
        });
        if (fileInputObj) {
          //将界面上的上传空间替换掉拖拽出来的上传控件，因为拖拽的控件无法识别ng2FileSelect等属性
          $('#' + fileInputObj.key)
            .find('.fileinput')
            .append($('.fileinput-hidden'));
          // $('#' + fileInputObj.key).find("[name=" + fileInputObj.field + "]")[0].addEventListener('change', (event) => {
          //     this.selectedFileOnChanged(event, fileInputObj.field);
          // });
          $('#' + fileInputObj.key)
            .find('.fileinput-hidden')[0]
            .addEventListener('change', (event) => {
              this.selectedFileOnChanged(event, fileInputObj.field);
            });
          $('#' + fileInputObj.key)
            .find('.clear')[0]
            .addEventListener('click', (event) => {
              this.setFormValue(fileInputObj.field, '');
            });
        } else {
          $('.fileinput-hidden').remove();
        }

        let stationOption = this._get(res, 'data.data.initLoad', '');
        console.log(stationOption);
        let initInputName = stationOption ? this._get(JSON.parse(stationOption), 'initInputName', '') : '';
        if (initInputName) {
          focusInput(initInputName);
        } else {
          let productSerialNoInput = this._find(this.customForms, { field: 'productSerialNo' });
          if (productSerialNoInput) {
            focusInput('productSerialNo');
          }
          let packIdInput = this._find(this.customForms, { field: 'packId' });
          if (packIdInput) {
            focusInput('packId');
          }
        }

        // //传递参数至接收组件中
        // this.operatorLayoutService.operatorLayoutEmitter.emit({
        //     workOrderNo: this.returnObject.workOrderNo,
        //     stationId: this.returnObject.stationId
        // });

        //默认加载函数
        this.onHttpRequestInit(stationOption);
        //加载回车事件函数
        this.onEnterHttpRequestInit();
        //加载点击事件函数
        this.onClickHttpRequestInit();
        //适配沃莱特多SN提交，提供Ctrl提交
        this.onCtrlHttpRequestInit();
        //记录项类型输入框回车事件函数
        this.onRecordItemEnter();
        //测试结果添加change事件
        this.eventResultChange();

        if (this.returnObject.stationCode) {
          this.setFormValue('stationCode', this.returnObject.stationCode);
        }
      });
    },

    /**
     * 自动扣减合格数
     */
    autoDeduction(item) {
      let unqualifiedQuantityInput = $('#attributeCopy').find('.unqualifiedQuantity input');
      this._forEach(unqualifiedQuantityInput, (inputItem) => {
        inputItem.onkeyup = null;
        inputItem.onkeyup = () => {
          // 判断是否开启自动扣减合格数
          if (item.isAutoDeduction) {
            // 超时调用
            setTimeout(() => {
              let unqualifiedQuantity = 0;
              this._forEach(unqualifiedQuantityInput, (unqualifiedQuantityInputItem) => {
                unqualifiedQuantity = Number(unqualifiedQuantity) + Number($(unqualifiedQuantityInputItem).val());
              });
              if (this.returnObject.finishedQuantity) {
                this.returnObject.finishedQuantity = Number(this.autoDeductionFinishedQuantity) - Number(unqualifiedQuantity);
              }
              this.setFormValue('finishedQuantity', this.returnObject.finishedQuantity);
            }, 80);
          }
        };
      });
    },

    /**
     * 重构动态表单数据
     * @param attribute 自定义属性
     */
    refactoringDynamicFormData(attribute) {
      return this._compact(attribute).map((obj) => {
        let cfModelAttribute = obj.cfModelAttribute;
        return {
          dataType: cfModelAttribute.dataType ? cfModelAttribute.dataType.toLowerCase() : 'input',
          labelName: cfModelAttribute.labelName,
          key: this._trim(cfModelAttribute.id),
          field: this._trim(cfModelAttribute.field),
          isRequired: cfModelAttribute.isRequired,
          defaultValue: this._trim(cfModelAttribute.defaultValue),
          placeholder: cfModelAttribute.placeholder,
          columnDefs: cfModelAttribute.columnDefs,
          optionField: cfModelAttribute.optionField,
          optionText: cfModelAttribute.optionText,
          dataSource: cfModelAttribute.dataSource,
          regexp: cfModelAttribute.regexp,
          options: cfModelAttribute.extendedFields,
          vehicleType: cfModelAttribute.vehicleType,
          vehicleTypeField: cfModelAttribute.vehicleTypeField,
          selectDataType: cfModelAttribute.selectDataType,
          isAutoDeduction: cfModelAttribute.isAutoDeduction,
          reference: cfModelAttribute.recordItem,
          isLocalStorage: cfModelAttribute.isLocalStorage,
          disabledInputName: cfModelAttribute.disabledInputName,
          createQrCode: cfModelAttribute.createQrCode,
          isHideModule: cfModelAttribute.isHideModule,
          defaultSelectDataCode: cfModelAttribute.defaultSelectDataCode,
          defaultSelectDataName: cfModelAttribute.defaultSelectDataName,
          optionListApi: cfModelAttribute.optionListApi,
          optionListApiCode: cfModelAttribute.optionListApiCode,
          dataSourceRequestParam: cfModelAttribute.dataSourceRequestParam,
          dataSourceFormat: cfModelAttribute.dataSourceFormat,
          chartHeight: cfModelAttribute.chartHeight,
          chartSourceList: cfModelAttribute.chartSourceList,
          beforeRequestData: cfModelAttribute.beforeRequestData,
          hideFormItemList: cfModelAttribute.hideFormItemList,
          isDefaultHide: cfModelAttribute.isDefaultHide,
          isEnableCache: cfModelAttribute.isEnableCache,
          isTogetherVerifyDuplicate: cfModelAttribute.isTogetherVerifyDuplicate,
          isCachePrintInfo: cfModelAttribute.isCachePrintInfo,
          isOpenDialogConfig: cfModelAttribute.isOpenDialogConfig,
          dialogUiConfig: cfModelAttribute.dialogUiConfig
        };
      });
    },

    /**
     * 功能初始化加载函数
     */
    onHttpRequestInit(stationOption) {
      //所有默认加载的方法
      let stationInitRequestList = stationOption ? this._get(JSON.parse(stationOption), 'initRequestList', []) : [];
      stationInitRequestList = this._filter(stationInitRequestList, (item) => {
        return item.id;
      });
      this.isShowSuccessMsg = false;
      console.log('-------------默认加载的API-------------');
      console.log(stationInitRequestList);
      this.httpRequest(stationInitRequestList, 0);
    },

    /**
     * 顺序发送HTTP请求
     * @param requestList
     * @param count
     */
    httpRequest(requestList, count) {
      if (count === 0 && this.inProgressField) {
        $('[name=' + this.inProgressField + ']').trigger('blur');
        this.inProgressField = '';
      }
      if (count >= requestList.length) {
        return;
      }
      // console.log(requestList);
      //目前适应一个通用数据API
      let currentRequest = requestList[count]; //当前请求的项
      if (currentRequest.apiType === 'OPERATION') {
        if (this.isCheckExpireMes) {
          this.$confirm('胶水已超出使用时长或已过期，请解绑已过期胶水后再进行工站作业！', '提示', {
            confirmButtonText: '确定',
            type: 'warning'
          });
          return;
        }
      }
      //是否内部服务
      // if (currentRequest.internal) {
      if (currentRequest.condition && currentRequest.condition !== 'SYSTEM_FAIL') {
        console.log(currentRequest.condition);
        if (currentRequest.condition === 'productList.length===standardQuantity') {
          let listLength = 0;
          if (currentRequest.isSupportMixPack) {
            listLength = this.mixPackProductList.length;
          } else {
            listLength = this.returnObject['productList'].length;
          }
          if (listLength === Number(this.returnObject['standardQuantity'])) {
            // console.log(`-------------第${count + 1}次请求的API地址以及参数-------------`);
            // console.log(encodeURI(currentRequest.url));

            //判断是否需要包装称重
            if (this.returnObject.isPackWeight && (this.returnObject.weightPoint === 'SEALING' || this.returnObject.weightPoint === 'BOTH')) {
              this.showPackWeightDialog = true;
              this.packWeightInfo.standardWeight = this.returnObject.sealingStandardWeight;
              this.packWeightInfo.weightUpper = this.returnObject.maxWeight2;
              this.packWeightInfo.weightLower = this.returnObject.minWeight2;
              setTimeout(() => {
                focusInput('weight');
              }, 500);
              this.httpRequestParams = {
                requestList: requestList,
                count: count,
                currentRequest: currentRequest
              };
              this.isAutomatic = true;
            } else {
              this.returnObject.weight = 0;
              this.httpRequestCommon(requestList, count, currentRequest);
            }
          } else {
            showSuccessLog('操作成功！');
            let isDisabled = $($('[name=' + currentRequest.componentTurnToInputName + ']')[0]).is(':disabled');
            if (!isDisabled) {
              selectInput(currentRequest.componentTurnToInputName);
            } else {
              selectInput(currentRequest.componentField);
            }
          }
        } else if (currentRequest.condition === 'packingList.length===standardQuantity') {
          //在线内包装工站判断是否达到包规
          if (this.returnObject.outerPackId) {
            if (this.returnObject['packingList'].length === Number(this.returnObject['standardQuantity'])) {
              // console.log(`-------------第${count + 1}次请求的API地址以及参数-------------`);
              // console.log(encodeURI(currentRequest.url));

              //判断是否需要包装称重
              if (this.returnObject.isPackWeight && (this.returnObject.weightPoint === 'SEALING' || this.returnObject.weightPoint === 'BOTH')) {
                this.showPackWeightDialog = true;
                this.packWeightInfo.standardWeight = this.returnObject.sealingStandardWeight;
                this.packWeightInfo.weightUpper = this.returnObject.maxWeight2;
                this.packWeightInfo.weightLower = this.returnObject.minWeight2;
                setTimeout(() => {
                  focusInput('weight');
                }, 500);
                this.httpRequestParams = {
                  requestList: requestList,
                  count: count,
                  currentRequest: currentRequest
                };
                this.isAutomatic = true;
              } else {
                this.returnObject.weight = 0;
                this.httpRequestCommon(requestList, count, currentRequest);
              }
            } else {
              showSuccessLog('操作成功！');
              let isDisabled = $($('[name=' + currentRequest.componentTurnToInputName + ']')[0]).is(':disabled');
              if (!isDisabled) {
                selectInput(currentRequest.componentTurnToInputName);
              } else {
                selectInput(currentRequest.componentField);
              }
            }
          } else {
            //在线外包装工站判断是否达到包规
            let innerPackIdQuantity = 0;
            this._forEach(this.returnObject['packingList'], (item) => {
              innerPackIdQuantity = innerPackIdQuantity + Number(item.standardQuantity);
            });
            if (innerPackIdQuantity === Number(this.returnObject['standardQuantity'])) {
              // console.log(`-------------第${count + 1}次请求的API地址以及参数-------------`);
              // console.log(encodeURI(currentRequest.url));

              //判断是否需要包装称重
              if (this.returnObject.isPackWeight && (this.returnObject.weightPoint === 'SEALING' || this.returnObject.weightPoint === 'BOTH')) {
                this.showPackWeightDialog = true;
                this.packWeightInfo.standardWeight = this.returnObject.sealingStandardWeight;
                this.packWeightInfo.weightUpper = this.returnObject.maxWeight2;
                this.packWeightInfo.weightLower = this.returnObject.minWeight2;
                setTimeout(() => {
                  focusInput('weight');
                }, 500);
                this.httpRequestParams = {
                  requestList: requestList,
                  count: count,
                  currentRequest: currentRequest
                };
                this.isAutomatic = true;
              } else {
                this.returnObject.weight = 0;
                this.httpRequestCommon(requestList, count, currentRequest);
              }
            } else {
              showSuccessLog('操作成功！');
              let isDisabled = $($('[name=' + currentRequest.componentTurnToInputName + ']')[0]).is(':disabled');
              if (!isDisabled) {
                selectInput(currentRequest.componentTurnToInputName);
              } else {
                selectInput(currentRequest.componentField);
              }
            }
          }
        }
        //判断载具产品数量是否达到或大于包规
        else if (currentRequest.condition === 'carrierProductQuantity>=standardQuantity') {
          let carrierProductQuantity = 0;
          this._forEach(this.returnObject['carrierList'], (item) => {
            carrierProductQuantity = Number(carrierProductQuantity) + Number(item.quantity);
          });
          if (carrierProductQuantity === Number(this.returnObject['standardQuantity']) || carrierProductQuantity > Number(this.returnObject['standardQuantity'])) {
            // console.log(`-------------第${count + 1}次请求的API地址以及参数-------------`);
            // console.log(encodeURI(currentRequest.url));
            this.httpRequestCommon(requestList, count, currentRequest);
          }
        }
        //判断是否开启外部序列号必填
        else if (currentRequest.condition === 'isSubmitExtendSequenceNumber') {
          if (!this.returnObject.isBindExternalSn) {
            this.httpRequestCommon(requestList, count, currentRequest);
          } else {
            focusInput(currentRequest.componentTurnToInputName);
          }
        }
        //判断扫描SN或条码时是否需要称重
        else if (currentRequest.condition === 'packWeight') {
          //判断是否需要包装称重
          if (this.returnObject.isPackWeight && (this.returnObject.weightPoint === 'BOXING' || this.returnObject.weightPoint === 'BOTH')) {
            this.showPackWeightDialog = true;
            this.packWeightInfo.standardWeight = this.returnObject.boxingStandardWeight;
            this.packWeightInfo.weightUpper = this.returnObject.maxWeight;
            this.packWeightInfo.weightLower = this.returnObject.minWeight;
            setTimeout(() => {
              focusInput('weight');
            }, 500);
            this.httpRequestParams = {
              requestList: requestList,
              count: count,
              currentRequest: currentRequest
            };
            this.isAutomatic = true;
          } else {
            showSuccessLog('操作成功！');
            this.httpRequestCommon(requestList, count, currentRequest);
          }
        }
        //判断待提交产品序列号是否存在
        else if (currentRequest.condition === "sequenceNumber != ''") {
          if (this.returnObject.sequenceNumberWait) {
            this.httpRequestCommon(requestList, count, currentRequest);
          }
          // else {
          //   this.httpRequestCommon(requestList, count + 1, requestList[count + 1]);
          // }
        }
        //判断输入的值是否是FAIL
        else if (currentRequest.condition === 'sequenceNumberWait != FAIL') {
          if (this.returnObject.sequenceNumberWait === 'FAIL') {
            // this.returnObject.sequenceNumberWait = '';
            // this.setFormValue('sequenceNumberWait', '');
            // this.returnObject.sequenceNumber = '';
            // this.setFormValue('sequenceNumber', '');
            this.httpRequestCommon(requestList, count + 1, requestList[count + 1]);
          } else {
            this.httpRequestCommon(requestList, count, currentRequest);
          }
        } else if (currentRequest.condition === 'scanProductList.length===needScanSerialList.unitQty') {
          let unitQtyTotal = 0;
          this._forEach(this.returnObject.needScanSerialList, (item) => {
            unitQtyTotal = Number(unitQtyTotal) + Number(item.unitQty);
          });
          if (this.returnObject.scanProductList.length === unitQtyTotal) {
            this.httpRequestCommon(requestList, count, currentRequest);
          } else {
            selectInput(currentRequest.componentField);
          }
        }
      } else {
        // console.log(`-------------第${count + 1}次请求的API地址以及参数-------------`);
        if (currentRequest.isEnableIntervalCall && currentRequest.IntervalTime) {
          this.httpRequestCommon(requestList, count, currentRequest);
          if (this.setIntervalList.length === 0) {
            this.setIntervalList.push('setInterval0');
            window['setInterval0'] = setInterval(() => {
              this.httpRequestCommon(requestList, requestList.length + 1, currentRequest);
            }, currentRequest.IntervalTime);
          } else {
            window['setInterval' + this.setIntervalList.length] = setInterval(() => {
              this.httpRequestCommon(requestList, requestList.length + 1, currentRequest);
            }, currentRequest.IntervalTime);
            this.setIntervalList.push('setInterval' + this.setIntervalList.length);
          }
        } else {
          this.httpRequestCommon(requestList, count, currentRequest);
        }
      }
      // } else {
      //   //外部请求
      //   this.$message({
      //     type: 'warning',
      //     message: 'waiting...'
      //   });
      // }
    },

    /**
     * 通用请求接口方法
     * @param requestList 当前操作组件的所有API
     * @param count 接口所处的索引
     * @param currentRequest 当前调用的接口对象
     */
    httpRequestCommon(requestList, count, currentRequest) {
      let paramsMap = {}; //调用接口时前端即将提交的参数
      let requestUrl = currentRequest.url; //API地址
      let httpMethod = currentRequest.httpMethod ? currentRequest.httpMethod.toLowerCase() : 'get'; //API请求的方式
      let paramMap = JSON.parse(this._get(currentRequest, 'paramsJson', '[]')); //API定义的请求参数
      let params = this._get(currentRequest, 'params', []);
      if (currentRequest.apiType === 'QUERY') {
        let parameterDatas = [];
        //查询类构造HTTP请求的参数
        parameterDatas = this._map(params, (paramsItem) => {
          let value = this.returnObject[paramsItem.code];
          let mapingCode = '';
          //如有映射字段则通过映射字段从页面中取值
          if (paramsItem.mapingCode) {
            value = this.returnObject[paramsItem.mapingCode];
            mapingCode = paramsItem.mapingCode;
          }
          //作为默认值，如有值则取默认值，不取页面中的值
          if (paramsItem.name) {
            value = paramsItem.name;
          }
          if (Array.isArray(value)) {
            value = JSON.stringify(value);
          }
          if (value === undefined || value === '') {
            let invalidObj = this._find(this.customForms, { field: paramsItem.code });
            if (invalidObj && invalidObj.isRequired === 'true') {
              if (invalidObj.dataType === 'radio') {
                value = $('[name=' + paramsItem.code + ']:checked').val();
              } else {
                value = $('[name=' + paramsItem.code + ']').val();
              }
              this.returnObject[paramsItem.code] = value;
            }
            if (invalidObj && invalidObj.dataType === 'table') {
              value = '[{}]';
            }
          }
          // if (value != undefined && value != null) {
          //   value = value.replace(/\s*/g, '');
          // }
          return {
            code: paramsItem.code,
            mapingCode: mapingCode,
            value: value
          };
        });
        if (parameterDatas.length === 0) {
          this.$confirm('查询类API请求参数缺少，请检查API配置中参数返回信息配置', '提示', {
            confirmButtonText: '确定',
            type: 'warning'
          });
          return;
        }
        paramsMap = {
          apiCode: currentRequest.code,
          parameterDatas: parameterDatas
        };
        // console.log(`-------------查询类参数-------------`);
        console.log(paramsMap);
        let undefinedValObject = this._find(parameterDatas, (paramItem) => {
          return paramItem.value === undefined || paramItem.value === '';
        });
        if (undefinedValObject) {
          let key = undefinedValObject.mapingCode ? undefinedValObject.mapingCode : undefinedValObject.code;
          let invalidObj = this._find(this.customForms, { field: key });
          if (invalidObj) {
            let dataType = this._get(invalidObj, 'dataType', '');
            if (dataType === 'input' || dataType === 'vehicle') {
              this.$confirm(`请输入${invalidObj.labelName}！`, '提示', {
                confirmButtonText: '确定',
                type: 'warning'
              });
              focusInput(invalidObj.field);
              return;
            } else {
              this.$confirm(`提交的参数中${invalidObj.labelName}信息为空，请检查是否输入！`, '提示', {
                confirmButtonText: '确定',
                type: 'warning'
              });
              focusInput(invalidObj.field);
              return;
            }
          } else {
            if (key !== 'apiCode') {
              this.$confirm(`界面上未找到字段名称为${key}的组件，请检查工站UI配置是否正确！`, '提示', {
                confirmButtonText: '确定',
                type: 'warning'
              });
              return;
            } else {
              this.$confirm(`提交的参数中${key}信息为空，请检查是否输入！`, '提示', {
                confirmButtonText: '确定',
                type: 'warning'
              });
              return;
            }
          }
        }
        this._forEach(paramsMap.parameterDatas, (item) => {
          delete item.mapingCode;
        });
      } else {
        //操作类构造HTTP请求的参数
        paramMap.push(
          { code: 'apiCode', value: '通用数据编码' },
          { code: 'workorderStationId', value: '工序绑定工位id' }
          // { code: 'routeStationId', value: '工站路由id' },
          // { code: 'workOrderId', value: '工单id' },
          // { code: 'sequenceNumber', value: '产品序列号' }
        );
        params.push(
          { code: 'apiCode', value: '通用数据编码' },
          { code: 'workorderStationId', value: '工序绑定工位id' }
          // { code: 'routeStationId', value: '工站路由id' },
          // { code: 'workOrderId', value: '工单号id' },
          // { code: 'sequenceNumber', value: '产品序列号' }
        );
        //区分地址栏是否有{}传参方式
        if (currentRequest.url.indexOf('{') !== -1 && currentRequest.url.indexOf('}') !== -1) {
          //请求参数
          for (const key in paramMap) {
            if (paramMap.hasOwnProperty(key)) {
              if (key.indexOf('{') !== -1 && key.indexOf('}') !== -1) {
                let mapingCodeObj = this._find(params, { code: key });
                let mapingCode = this._get(mapingCodeObj, 'mapingCode', '');
                let name = this._get(mapingCodeObj, 'name', '');
                //映射字段不为空时通过映射字段取页面中的值
                if (mapingCode) {
                  this.returnObject[paramMap[key]] = this.returnObject[mapingCode];
                }
                //默认值不为空时API参数取默认值不从页面中取值
                if (name) {
                  this.returnObject[paramMap[key]] = name;
                }
                if (this.returnObject[paramMap[key]] !== '' && this.returnObject[paramMap[key]] !== undefined && this.returnObject[paramMap[key]] !== null) {
                  //通过配置中的带有{}参数来替换url中所需的参数
                  requestUrl = requestUrl.replace(key, this.returnObject[paramMap[key]]);
                } else {
                  let _val = $('[name=' + paramMap[key] + ']').val();
                  if (_val) {
                    requestUrl = requestUrl.replace(key, _val);
                  } else {
                    let invalidObj = this._find(this.customForms, { field: paramMap[key] });
                    if (!paramsMap[key]) {
                      if (invalidObj) {
                        if (invalidObj.dataType === 'input' || invalidObj.dataType === 'vehicle') {
                          this.$confirm(`请输入${invalidObj.labelName}！`, '提示', {
                            confirmButtonText: '确定',
                            type: 'warning'
                          });
                          focusInput(invalidObj.field);
                          return;
                        } else {
                          this.$confirm(`提交的参数中${invalidObj.labelName}信息为空，请检查是否输入！`, '提示', {
                            confirmButtonText: '确定',
                            type: 'warning'
                          });
                          focusInput(invalidObj.field);
                          return;
                        }
                      } else {
                        //APICode不存在组件中，所以需要排除
                        if (key !== 'apiCode') {
                          this.$confirm(`界面上未找到字段名称为${key}的组件，请检查工站UI配置是否正确！`, '提示', {
                            confirmButtonText: '确定',
                            type: 'warning'
                          });
                          return;
                        } else {
                          this.$confirm(`提交的参数中${key}信息为空，请检查是否输入！`, '提示', {
                            confirmButtonText: '确定',
                            type: 'warning'
                          });
                          return;
                        }
                      }
                    }
                  }
                }
              } else {
                //若该请求配置的参数不存在该表单中，也就是值为undefined则不提交该参数
                if (this.returnObject[key] !== undefined) {
                  if (key.indexOf('Date') !== -1) {
                    let dateId = moment(this.returnObject[paramMap[key]], 'YYYY-MM-DD HH:mm:ss').valueOf(); //时间格式转换为时间戳
                    paramsMap[key] = dateId;
                  } else {
                    paramsMap[key] = this.returnObject[key];
                  }
                } else {
                  if (key === 'apiCode') {
                    paramsMap[key] = currentRequest.code;
                  } else {
                    let invalidObj = this._find(this.customForms, { field: key });
                    if (invalidObj && invalidObj.isRequired === 'true') {
                      if (invalidObj.dataType === 'radio') {
                        paramsMap[key] = $('[name=' + key + ']:checked').val();
                      } else {
                        paramsMap[key] = $('[name=' + key + ']').val();
                      }
                    }
                  }
                }
              }
            }
          }
        } else {
          //实体请求参数
          if (params.length > 0) {
            /**
             * 数组存储参数形式
             */
            this._forEach(params, (paramsItem) => {
              let key = paramsItem.code;
              let inputValue = this.returnObject[key];
              //若存在映射字段则获取映射字段的值
              if (this._trim(paramsItem.mapingCode)) {
                inputValue = this.returnObject[paramsItem.mapingCode];
              }
              console.log(inputValue);
              //若存在默认值则获取默认值
              if (this._trim(paramsItem.name)) {
                inputValue = paramsItem.name;
              }
              //若该请求配置的参数不存在返回值对象中，则取界面上寻找该组件的值
              if (inputValue !== undefined && inputValue !== '') {
                // if (inputValue != null) {
                //   inputValue = inputValue.replace(/\s*/g, '');
                // }
                if (key.indexOf('Date') !== -1) {
                  let dateId = moment(this.returnObject[paramMap[key]], 'YYYY-MM-DD HH:mm:ss').valueOf(); //时间格式转换为时间戳
                  paramsMap[key] = dateId;
                } else {
                  switch (key) {
                    // case 'printId':
                    //   //实现单个打印机和单个打印模板
                    //   paramsMap[key] = new Array();
                    //   paramsMap[key] = [inputValue];
                    //   break;
                    // case 'labelTemplateId':
                    //   paramsMap[key] = new Array();
                    //   paramsMap[key] = [inputValue];
                    //   break;
                    case 'attributes':
                      this._forEach(params, (paramsITEM) => {
                        let $td = $(`[data-name="${paramsITEM.code}"]`);
                        if ($td.length > 0) {
                          if (paramsITEM.code === 'examinedResult') {
                            paramsMap[paramsITEM.code] = $td.find('input:radio[name="examinedResult"]:checked').val();
                          } else {
                            paramsMap[paramsITEM.code] = $td.find('.input-control').val();
                          }
                        }
                      });

                      let attributes = this._map(this.returnObject[key], (attributesItem) => {
                        let $trTds = $('#' + attributesItem.id).find('td');
                        $trTds.each((index, td) => {
                          var dataName = $(td).attr('data-name');
                          attributesItem[dataName] = $(td).find('.input-control').val();
                        });
                        return attributesItem;
                      });
                      console.log(attributes);
                      paramsMap[key] = attributes;
                      break;
                    case 'productList':
                      if (this.showMixPackDialog) {
                        paramsMap[key] = this.mixPackProductList;
                      } else {
                        paramsMap[key] = inputValue;
                      }
                      break;
                    case 'isSupportMixPack':
                      if (this.showMixPackDialog) {
                        paramsMap[key] = true;
                      } else {
                        paramsMap[key] = false;
                        for (let i = 0; i < paramsMap['productList'].length; i++) {
                          if (paramsMap['productList'][i].workOrderNo != this.returnObject.workOrderNo) {
                            paramsMap[key] = true;
                            break;
                          }
                        }
                      }
                      break;
                    default:
                      let formObj = this._find(this.customForms, { field: paramsItem.code });
                      if (formObj && formObj.regexp) {
                        let regexpValue = inputValue;
                        if (regexpValue) {
                          regexpValue = this._trim(regexpValue);
                          paramsMap[key] = regexpValue;
                        } else {
                          paramsMap[key] = inputValue;
                        }
                      } else {
                        paramsMap[key] = inputValue;
                      }
                      break;
                  }
                }
              } else {
                if (key === 'apiCode') {
                  paramsMap[key] = currentRequest.code;
                } else if (key === 'productList') {
                  if (this.showMixPackDialog) {
                    paramsMap[key] = this.mixPackProductList;
                  } else {
                    paramsMap[key] = this.returnObject[key];
                  }
                } else {
                  let inputName = key;
                  if (this._trim(paramsItem.mapingCode)) {
                    inputName = this._trim(paramsItem.mapingCode);
                  }
                  console.log(this.customForms, inputName);
                  let invalidObj = this._find(this.customForms, { field: inputName });
                  if (invalidObj) {
                    if (invalidObj.dataType === 'radio') {
                      paramsMap[key] = $('[name=' + inputName + ']:checked').val();
                    } else if (invalidObj.dataType === 'input') {
                      if ($('[name=' + inputName + ']').val() != undefined && $('[name=' + inputName + ']').val() != null) {
                        paramsMap[key] = $('[name=' + inputName + ']')
                          .val()
                          .replace(/\s*/g, '');
                      } else {
                        console.log(invalidObj);
                        paramsMap[key] = $('[name=' + inputName + ']').val();
                      }
                    } else if (invalidObj.dataType === 'extended-fields') {
                      if (!paramsItem.mapingCode) {
                        let obj = this._find(this.customForms, { dataType: 'extended-fields' });
                        if (obj && obj.options && obj.options.length > 0) {
                          let options = {};
                          this._forEach(obj.options, (item) => {
                            let extendedFieldsList = $('#extendedFieldsList').find('.extendedFields');
                            this._forEach(extendedFieldsList, (listItem) => {
                              if (item.headerName === $(listItem).find('label span').text()) {
                                options[item.field] = item.type === 'select' ? $(listItem).find('select').val() : $(listItem).find('input').val();
                              }
                            });
                          });
                          paramsMap[key] = JSON.stringify(options);
                        }
                      } else {
                        let obj = this._find(this.customForms, { dataType: 'extended-fields' });
                        if (obj && obj.options && obj.options.length > 0) {
                          let options = [];
                          this._forEach(obj.options, (item) => {
                            let extendedFieldsList = $('#extendedFieldsList').find('.extendedFields');
                            this._forEach(extendedFieldsList, (listItem) => {
                              if (item.headerName === $(listItem).find('label span').text()) {
                                options.push({ [item.field]: item.type === 'select' ? $(listItem).find('select').val() : $(listItem).find('input').val() });
                              }
                            });
                          });
                          paramsMap[key] = JSON.stringify(options);
                        }
                      }
                    } else if (invalidObj.dataType === 'attribute-copy') {
                      //适配联盈多个不良代码选择
                      let failureList = [];
                      let failureCodeList = $('#attributeCopy').find('.failureCode');
                      let unqualifiedQuantityList = $('#attributeCopy').find('.unqualifiedQuantity');
                      for (let i = 0; i < failureCodeList.length; i++) {
                        let item = failureCodeList[i];
                        if ($(item).find('input').val() && $(unqualifiedQuantityList[i]).find('input').val()) {
                          failureList.push({
                            failureCode: $(item).find('input').val(),
                            unqualifiedQuantity: $(unqualifiedQuantityList[i]).find('input').val()
                          });
                        }
                      }
                      paramsMap[key] = failureList;
                    } else if (invalidObj.dataType === 'multiple-print') {
                      //适配沃莱特打多个标签
                      let multiplePrintList = [];
                      let printerList = $('#multiplePrint').find('.print');
                      let labelTemplateList = $('#multiplePrint').find('.labelTemplate');
                      for (let i = 0; i < printerList.length; i++) {
                        let item = printerList[i];
                        if ($(item).find('input').val() && $(labelTemplateList[i]).find('input').val()) {
                          multiplePrintList.push(this.extraPrint[i]);
                        }
                      }
                      paramsMap[key] = multiplePrintList;
                    } else if (invalidObj.dataType === 'record-item') {
                      let obj = this._find(this.customForms, { dataType: 'record-item' });
                      if (obj && obj.reference && obj.reference.length > 0) {
                        let reference = [];
                        let extendedFieldsList = $('#recordItemList').find('.recordItem');
                        this._forEach(extendedFieldsList, (listItem) => {
                          let referenceItem = {};
                          if ($(listItem).find('input').val()) {
                            referenceItem[$(listItem).find('label span').text().replace('*', '')] = $(listItem).find('input').val();
                            reference.push(referenceItem);
                          }
                        });
                        paramsMap[key] = JSON.stringify(reference);
                      }
                    } else {
                      paramsMap[key] = $('[name=' + inputName + ']').val();
                    }
                  }
                  // else {
                  //   paramsMap[key] = this.returnObject[key];
                  // }
                }
              }
            });
          } else {
            /**
             * 对象存储参数形式
             */
            for (const key in paramMap) {
              if (paramMap.hasOwnProperty(key)) {
                //若该请求配置的参数不存在返回值对象中，则取界面上寻找该组件的值
                if (this.returnObject[key] !== undefined && this.returnObject[key] !== '') {
                  // if (this.returnObject[key] != null) {
                  //   this.returnObject[key] = this.returnObject[key].replace(/\s*/g, '');
                  // }
                  if (key.indexOf('Date') !== -1) {
                    let dateId = moment(this.returnObject[paramMap[key]], 'YYYY-MM-DD HH:mm:ss').valueOf(); //时间格式转换为时间戳
                    paramsMap[key] = dateId;
                  } else {
                    // switch (key) {
                    //   case 'printId':
                    //     //实现单个打印机和单个打印模板
                    //     paramsMap[key] = new Array();
                    //     paramsMap[key] = [this.returnObject[key]];
                    //     break;
                    //   case 'labelTemplateId':
                    //     paramsMap[key] = new Array();
                    //     paramsMap[key] = [this.returnObject[key]];
                    //     break;
                    //   default:
                    paramsMap[key] = this.returnObject[key];
                    // break;
                    // }
                  }
                } else {
                  if (key === 'apiCode') {
                    paramsMap[key] = currentRequest.code;
                  } else {
                    let invalidObj = this._find(this.customForms, { field: key });
                    if (invalidObj) {
                      if (invalidObj.dataType === 'radio') {
                        paramsMap[key] = $('[name=' + key + ']:checked').val();
                      } else {
                        // if (paramsMap[key] != undefined && paramsMap[key] != null) {
                        //   paramsMap[key] = $('[name=' + key + ']').val().replace(/\s*/g, '');
                        // } else {
                        paramsMap[key] = $('[name=' + key + ']').val();
                        // }
                      }
                    }
                  }
                }
              }
            }
          }
          requestUrl = currentRequest.url;
        }
        //实体{}中的参数验证，若参数中有必填项回车提交时若为空则弹出提示
        for (const key in paramsMap) {
          if (paramsMap.hasOwnProperty(key)) {
            //若参数存在动态表单中
            let mapingCodeObj = this._find(params, { code: key });
            let mapingCode = this._get(mapingCodeObj, 'mapingCode', '');
            let invalidObj;
            if (mapingCode) {
              invalidObj = this._find(this.customForms, { field: mapingCode });
            } else {
              invalidObj = this._find(this.customForms, { field: key });
            }

            if (key === 'reference') {
              if (invalidObj.dataType === 'record-item' && invalidObj.reference) {
                let reference = invalidObj.reference;
                for (let i = 0; i < reference.length; i++) {
                  if (reference[i].isRequired && !$('[name=' + reference[i].headerFile + ']').val()) {
                    this.$confirm(`请输入${reference[i].headerName}！`, '提示', {
                      confirmButtonText: '确定',
                      type: 'warning'
                    });
                    focusInput(reference[i].headerFile);
                    return;
                  }
                }
              }
            }
            if (key === 'failureList') {
              let failureCodeList = $('#attributeCopy').find('.failureCode');
              let unqualifiedQuantityList = $('#attributeCopy').find('.unqualifiedQuantity');
              for (let i = 0; i < failureCodeList.length; i++) {
                let item = failureCodeList[i];
                if ($(item).find('input').val() && !$(unqualifiedQuantityList[i]).find('input').val()) {
                  this.$confirm(`请输入${$(item).find('label span').text()}的数量！`, '提示', {
                    confirmButtonText: '确定',
                    type: 'warning'
                  });
                  return;
                }
                if (!$(item).find('input').val() && $(unqualifiedQuantityList[i]).find('input').val()) {
                  this.$confirm(`请选择${$(item).find('label span').text()}！`, '提示', {
                    confirmButtonText: '确定',
                    type: 'warning'
                  });
                  return;
                }
              }
            }
            if (key === 'extraPrint') {
              let printerList = $('#multiplePrint').find('.print');
              let labelTemplateList = $('#multiplePrint').find('.labelTemplate');
              for (let i = 0; i < printerList.length; i++) {
                let item = printerList[i];
                if ($(item).find('input').val() && !$(labelTemplateList[i]).find('input').val()) {
                  this.$confirm(`请选择${$(labelTemplateList[i]).find('label span').text()}！`, '提示', {
                    confirmButtonText: '确定',
                    type: 'warning'
                  });
                  return;
                }
                if (!$(item).find('input').val() && $(labelTemplateList[i]).find('input').val()) {
                  this.$confirm(`请选择${$(item).find('label span').text()}！`, '提示', {
                    confirmButtonText: '确定',
                    type: 'warning'
                  });
                  return;
                }
              }
            }

            if (!paramsMap[key]) {
              if (invalidObj) {
                if (invalidObj.isRequired === 'true') {
                  if (invalidObj.dataType === 'input' || invalidObj.dataType === 'vehicle' || invalidObj.dataType === 'select') {
                    this.$confirm(`请输入${invalidObj.labelName}！`, '提示', {
                      confirmButtonText: '确定',
                      type: 'warning'
                    });
                    focusInput(invalidObj.field);
                    return;
                  } else {
                    setTimeout(() => {
                      this.$confirm(`提交的参数中${invalidObj.labelName}信息为空，请检查是否输入！`, '提示', {
                        confirmButtonText: '确定',
                        type: 'warning'
                      });
                    }, 500);
                    focusInput(invalidObj.field);
                    return;
                  }
                }
              } else {
                //APICode不存在组件中，所以需要排除
                if (key !== 'apiCode' && key !== 'weight' && mapingCode !== 'mixPackSequenceNumber' && key !== 'isSupportMixPack') {
                  // this.layerFailMsg(`界面上未找到字段名称为 ${key} 的组件，请检查工站UI配置是否正确！`, key);
                  this.$confirm(`界面上未找到字段名称为${key}的组件，请检查工站UI配置是否正确！`, '提示', {
                    confirmButtonText: '确定',
                    type: 'warning'
                  });
                  return;
                } else {
                  if (key !== 'weight' && key !== 'isSupportMixPack') {
                    // this.layerFailMsg('提交的参数中 ' + key + ' 信息为空，请检查是否输入！', key);
                    setTimeout(() => {
                      this.$confirm(`提交的参数中${key}信息为空，请检查是否输入！`, '提示', {
                        confirmButtonText: '确定',
                        type: 'warning'
                      });
                    }, 500);
                    return;
                  }
                }
              }
            }
          }
        }
        for (let i = 0; i < params.length; i++) {
          let invalidObj;
          if (params[i].mapingCode) {
            invalidObj = this._find(this.customForms, { field: params[i].mapingCode });
          } else {
            invalidObj = this._find(this.customForms, { field: params[i].code });
          }
          if (invalidObj && invalidObj.isRequired === 'true') {
            if (invalidObj.dataType === 'input' && $('[name=' + invalidObj.field + ']').attr('type') === 'number') {
              let reg = /^((0{1}\.\d{1,2})|([1-9]\d*\.{1}\d{1,2})|([1-9]+\d*))$/g;
              if (!reg.test($('[name=' + invalidObj.field + ']').val())) {
                selectInput(invalidObj.field);
                this.$message({
                  type: 'warning',
                  message: `${invalidObj.labelName}应大于0，且只能保留两位小数！`
                });
                showWarningLog(`${invalidObj.labelName}应大于0，且只能保留两位小数！`);
                return;
              }
            }
          }
        }
        console.log(`-------------操作类参数-------------`);
        console.log(paramsMap);
      }
      if (this.isRequestComplete) {
        this.isRequestComplete = false;
        request({
          url: encodeURI(requestUrl),
          method: httpMethod,
          data: paramsMap
        }).then(
          (res) => {
            // console.log(`-------------第${count + 1}次请求的响应结果-------------`);
            // console.log(res);
            this.isRequestComplete = true;
            if (currentRequest.multiple) {
              //返回List
            } else {
              if (currentRequest.apiType === 'QUERY') {
                // console.log(currentRequest);
                //查询类API返回信息，同样适用操作类的返回成功数据来渲染数据
                //componentField表示数据KEY值，对应到界面上的组件字段
                //apiField表示数据库字段、对象（{productSerialNo}）或者数据[]
                let data = this._get(res, 'data.data', []);
                if (data.length === 1) {
                  //返回字符串信息
                  var returnFieldMap = { ...this._get(res, 'data.data[0]', {}) };
                  // console.log(returnFieldMap);
                  //操作类API返回信息
                  //根据在通用数据配置好的输入框Name值来渲染INPUT值或者清空INPUT，若配置的Name值不存在生成的动态表单中则不进行设置空
                  for (let i = 0; i < currentRequest.successDoList.length; i++) {
                    let successItem = currentRequest.successDoList[i];
                    // this._forEach(currentRequest.successDoList, (successItem) => {
                    let key = successItem.componentField;
                    let val = returnFieldMap[successItem.apiField];
                    //查询配置的返回信息在UI界面是否存在
                    let component = this._find(this.customForms, { field: key });
                    if (component) {
                      switch (component.dataType) {
                        case 'card':
                          this.returnObject[key] = val;
                          //卡片使用Id去查找并赋值
                          this.setCardValue(component.key, val);
                          break;
                        case 'input':
                          if (successItem.apiField.indexOf('${') != -1) {
                            let ele = $('[name=' + key + ']').parent();
                            $('.prompt').empty();
                            let newEle = '';
                            let fieldValue = 'xxxxxx';
                            for (let fieldItem in returnFieldMap) {
                              if (returnFieldMap[`${fieldItem}`]) {
                                fieldValue = returnFieldMap[`${fieldItem}`];
                              }
                              newEle = `<div class="prompt">${successItem.apiField}</div>`.replace('${' + fieldItem + '}', fieldValue);
                            }
                            $(ele[0]).css('margin-bottom', '0');
                            $(ele[0]).after(newEle);
                          } else {
                            this.returnObject[key] = val;
                            //表单输入框使用field去查找并赋值
                            this.setFormValue(key, val);
                            if (key === 'finishedQuantity') {
                              this.autoDeductionFinishedQuantity = this._cloneDeep(this.returnObject.finishedQuantity);
                            }
                          }
                          break;
                        case 'info-input':
                          if (successItem.apiField.indexOf('sum') != -1) {
                            let total = 0;
                            if (successItem.apiField.indexOf('.') != -1) {
                              let fieldArr = successItem.apiField.replace('sum(', '').replace(')', '').split('.');
                              this._forEach(this.returnObject[fieldArr[0]], (item) => {
                                total = Number(total) + Number(item[fieldArr[1]]);
                              });
                              if (key + this.returnObject.workorderStationId != localStorage.beforeTotalFinishedQuantity) {
                                localStorage.removeItem(localStorage.beforeTotalFinishedQuantity);
                              }
                              localStorage.setItem(key + this.returnObject.workorderStationId, total);
                              localStorage.setItem('beforeTotalFinishedQuantity', key + this.returnObject.workorderStationId);
                            } else if (successItem.apiField === 'sum()') {
                              this.returnObject[key] = '';
                              total = '';
                              localStorage.setItem(key + this.returnObject.workorderStationId, this.returnObject[key]);
                            } else {
                              let fieldStr = successItem.apiField.replace('sum(', '').replace(')', '');
                              total = this.returnObject[successItem.componentField]
                                ? Number(this.returnObject[successItem.componentField]) + Number(this.returnObject[fieldStr])
                                : Number(this.returnObject[fieldStr]);
                            }
                            this.returnObject[successItem.componentField] = total;
                            this.setFormValue(key, total);
                          } else {
                            this.returnObject[key] = val;
                            //表单输入框使用field去查找并赋值
                            this.setFormValue(key, val);
                          }
                          if (key === 'finishedQuantity') {
                            this.autoDeductionFinishedQuantity = this._cloneDeep(this.returnObject.finishedQuantity);
                          }
                          break;
                        case 'select-data':
                          this.returnObject[key] = val;
                          //表单输入框使用field去查找并赋值
                          this.setFormValue(key, val);
                          break;
                        case 'print-label':
                          this.returnObject[key] = val;
                          //表单输入框使用field去查找并赋值
                          this.setFormValue(key, val);
                          break;
                        case 'table':
                          console.log(successItem.apiField);
                          /**
                           * 存在情况：
                           * 1.显示后端返回data[0].list中list的值
                           * 2.将某一条记录查询出来添加到表格中，最后保存时提交整个表格，配置为{packId};现修改为可配置为子查询也可不配置
                           * 3.将某一条记录查询出来然后增加属性值添加到表格中，最后保存时提交整个表格，配置为{packId};现修改为可配置为子查询也可不配置
                           */
                          if (successItem.apiField === '{' + successItem.componentField + '}') {
                            //只是将记录添加到表格中
                            let returnFieldList = [];
                            //直接将查询出来的对象添加进表格中
                            if (returnFieldMap.hasOwnProperty(successItem.componentField)) {
                              //直接将查询出来的对象添加进表格中
                              returnFieldList = this._get(returnFieldMap, successItem.componentField, []);
                            } else {
                              returnFieldList = [returnFieldMap];
                            }
                            let returnFieldObject = this._get(returnFieldList, '[0]', {});
                            //当配置的数据库返回值为组件的字段加上{}则表示将此记录添加进表格中
                            if (JSON.stringify(returnFieldObject) === '{}') {
                              this.$confirm(`查询到的数据为空，请重新扫描${currentRequest.componentName}`, '提示', {
                                confirmButtonText: '确定',
                                type: 'warning'
                              }).then(() => {
                                selectInput(currentRequest.componentField);
                              });
                              return;
                            }
                            console.log('查询返回表格数据');
                            console.log(returnFieldObject, this.returnObject[key], key);
                            if (!Array.isArray(this.returnObject[key])) {
                              this.returnObject[key] = new Array();
                            }
                            //判断序列号是否重复
                            let verifyDuplicate = this._find(component.columnDefs, { isVerifyDuplicate: true });
                            let verifyDuplicateObj = {};
                            let repeat = [];
                            let repeatVal = '';
                            let repeatField = '';
                            let repeatMsg = '';
                            if (verifyDuplicate != undefined) {
                              repeatVal = this._get(returnFieldObject, currentRequest.componentField, '');
                              this._forEach(component.columnDefs, (item) => {
                                if (item.isVerifyDuplicate) {
                                  verifyDuplicateObj[item.field] = returnFieldObject[item.field];
                                }
                              });
                              if (component.isTogetherVerifyDuplicate) {
                                let index;
                                for (let fieldKey in verifyDuplicateObj) {
                                  index = this._findIndex(this.returnObject[key], { [fieldKey]: verifyDuplicateObj[fieldKey] });
                                  if (index != -1) {
                                    repeat.push(this.returnObject[key][index]);
                                    if (!repeatField) {
                                      repeatField = fieldKey;
                                    }
                                    let columnObj = this._find(component.columnDefs, { field: fieldKey });
                                    repeatMsg = `${columnObj.headerName} ${this.returnObject[key][index][fieldKey]}`;
                                    break;
                                  }
                                }
                              } else {
                                let duplicateObj = this._find(this.returnObject[key], verifyDuplicateObj);
                                if (duplicateObj != undefined) {
                                  repeat.push(duplicateObj);
                                  repeatMsg = `${currentRequest.componentName} ${repeatVal}`;
                                }
                              }
                            } else {
                              repeatVal = this._get(returnFieldObject, currentRequest.componentField, '');
                              //匹配是否重复的主键
                              let keyField = currentRequest.componentField;
                              repeat = this._filter(this.returnObject[key], (filterItem) => {
                                return filterItem[keyField] === repeatVal;
                              });
                              repeatMsg = `${currentRequest.componentName} ${repeatVal}`;
                            }
                            if (repeat.length > 0) {
                              // this.layerFailMsg(`${currentRequest.componentName} ${repeatVal} 已经被添加到表格中了，请不要重复添加`, currentRequest.componentField);
                              this.$confirm(`${repeatMsg} 已经被添加到表格中了，请不要重复添加`, '提示', {
                                confirmButtonText: '确定',
                                type: 'warning'
                              }).then(() => {
                                if (repeatField) {
                                  selectInput(repeatField);
                                }
                              });
                              return;
                            } else {
                              if (component.field === 'productList' && this.returnObject['standardQuantity']) {
                                let msg = '';
                                if (this.returnObject.isPackWeight) {
                                  msg = `扫描的${currentRequest.componentName}  已经超出包装数量，请称重封箱`;
                                } else {
                                  msg = `扫描的${currentRequest.componentName}  已经超出包装数量，请封箱`;
                                }
                                if (this.returnObject['productList'].length + 1 > Number(this.returnObject['standardQuantity'])) {
                                  this.$confirm(msg, '提示', {
                                    confirmButtonText: '确定',
                                    type: 'warning'
                                  });
                                  return;
                                } else {
                                  if (this.returnObject.weight) {
                                    returnFieldObject['weight'] = this.returnObject.weight;
                                  }
                                  this.returnObject[key].unshift(returnFieldObject);
                                  this.setTableValue(component, this.returnObject[key]);
                                }
                              } else if (component.field === 'packingList' && this.returnObject['standardQuantity']) {
                                //在线外包装工站判断是否达到包规
                                let msg = '';
                                if (this.returnObject.isPackWeight) {
                                  msg = `扫描的${currentRequest.componentName}  已经超出包装数量，请称重封箱`;
                                } else {
                                  msg = `扫描的${currentRequest.componentName}  已经超出包装数量，请封箱`;
                                }
                                let innerPackIdQuantity = 0;
                                this._forEach(this.returnObject['packingList'], (item) => {
                                  innerPackIdQuantity = innerPackIdQuantity + Number(item.standardQuantity);
                                });
                                if (Number(returnFieldObject.standardQuantity) + innerPackIdQuantity > Number(this.returnObject['standardQuantity'])) {
                                  this.$confirm(msg, '提示', {
                                    confirmButtonText: '确定',
                                    type: 'warning'
                                  });
                                  return;
                                } else {
                                  if (this.returnObject.weight) {
                                    returnFieldObject['weight'] = this.returnObject.weight;
                                  }
                                  this.returnObject[key].unshift(returnFieldObject);
                                  this.setTableValue(component, this.returnObject[key]);
                                }
                              } else {
                                this.returnObject[key].unshift(returnFieldObject);
                                this.setTableValue(component, this.returnObject[key]);
                              }
                            }
                          }
                          //适配沃莱特多SN包装
                          else if (successItem.apiField === '[' + successItem.componentField + ']') {
                            let returnFieldArry = [];
                            let returnFieldObjectList = [];
                            //直接将查询出来的对象添加进表格中
                            if (returnFieldMap.hasOwnProperty(successItem.componentField)) {
                              //直接将查询出来的对象添加进表格中
                              let fieldList = this._get(returnFieldMap, successItem.componentField, []);
                              returnFieldArry = fieldList;
                            } else {
                              returnFieldArry = [returnFieldMap];
                            }
                            //当配置的数据库返回值为组件的字段加上[]则表示将此数组记录添加进表格中
                            if (!Array.isArray(this.returnObject[key])) {
                              this.returnObject[key] = new Array();
                            }
                            //判断序列号是否重复
                            let repeatValList = [];
                            let verifyDuplicate = this._find(component.columnDefs, { isVerifyDuplicate: true });
                            if (this.returnObject[key].length > 0) {
                              this._forEach(returnFieldArry, (returnFieldObject) => {
                                let count = 0;
                                // for (let i = 0; i < this.returnObject[key].length; i++) {
                                let repeatVal = this._find(this.returnObject[key], returnFieldObject);
                                if (repeatVal) {
                                  count++;
                                  if (verifyDuplicate != undefined) {
                                    if (verifyDuplicate.field === currentRequest.params[0].code) {
                                      repeatValList.push(repeatVal[currentRequest.params[0].code]);
                                    } else {
                                      repeatValList.push(repeatVal[verifyDuplicate.field]);
                                    }
                                  } else {
                                    repeatValList.push(repeatVal[currentRequest.params[0].code]);
                                  }
                                  // break;
                                }
                                // }
                                if (count === 0) {
                                  returnFieldObjectList.push(returnFieldObject);
                                }
                              });
                              if (component.field === 'productList' && this.returnObject['standardQuantity']) {
                                if (this.returnObject['productList'].length + returnFieldObjectList.length > Number(this.returnObject['standardQuantity'])) {
                                  this.$confirm(`扫描的${currentRequest.params[0].value}  已经超出包装数量`, '提示', {
                                    confirmButtonText: '确定',
                                    type: 'warning'
                                  });
                                  return;
                                } else {
                                  this._forEach(returnFieldObjectList, (item) => {
                                    this.returnObject[key].unshift(item);
                                  });
                                }
                              } else if (component.field === 'packingList' && this.returnObject['standardQuantity']) {
                                //在线内包装工站判断是否达到包规
                                if (this.returnObject.outerPackId) {
                                  if (this.returnObject['packingList'].length + returnFieldObjectList.length > Number(this.returnObject['standardQuantity'])) {
                                    this.$confirm(`扫描的${currentRequest.params[0].value}  已经超出包装数量`, '提示', {
                                      confirmButtonText: '确定',
                                      type: 'warning'
                                    });
                                    return;
                                  } else {
                                    this._forEach(returnFieldObjectList, (item) => {
                                      this.returnObject[key].unshift(item);
                                    });
                                  }
                                } else {
                                  //在线外包装工站判断是否达到包规
                                  let innerPackIdQuantity = 0;
                                  this._forEach(this.returnObject['packingList'], (item) => {
                                    innerPackIdQuantity = innerPackIdQuantity + Number(item.standardQuantity);
                                  });
                                  this._forEach(returnFieldObjectList, (item) => {
                                    if (Number(item.standardQuantity) + innerPackIdQuantity > Number(this.returnObject['standardQuantity'])) {
                                      if (this.returnObject['packingList'].length + returnFieldObjectList.length > Number(this.returnObject['standardQuantity'])) {
                                        this.$confirm(`扫描的${currentRequest.params[0].value}  已经超出包装数量`, '提示', {
                                          confirmButtonText: '确定',
                                          type: 'warning'
                                        });
                                        return;
                                      }
                                    } else {
                                      this._forEach(returnFieldObjectList, (item) => {
                                        this.returnObject[key].unshift(item);
                                      });
                                    }
                                  });
                                }
                              } else {
                                this._forEach(returnFieldObjectList, (item) => {
                                  this.returnObject[key].unshift(item);
                                });
                              }
                            } else {
                              if (component.field === 'productList' && this.returnObject['standardQuantity']) {
                                if (this.returnObject['productList'].length + returnFieldArry.length > Number(this.returnObject['standardQuantity'])) {
                                  this.$confirm(`扫描的${currentRequest.params[0].value}  已经超出包装数量`, '提示', {
                                    confirmButtonText: '确定',
                                    type: 'warning'
                                  });
                                  return;
                                } else {
                                  this.returnObject[key] = returnFieldArry.reverse();
                                }
                              } else if (component.field === 'packingList' && this.returnObject['standardQuantity']) {
                                //在线内包装工站判断是否达到包规
                                if (this.returnObject.outerPackId) {
                                  if (this.returnObject['packingList'].length + returnFieldArry.length > Number(this.returnObject['standardQuantity'])) {
                                    this.$confirm(`${currentRequest.params[0].value}  已经超出包装数量`, '提示', {
                                      confirmButtonText: '确定',
                                      type: 'warning'
                                    });
                                    return;
                                  } else {
                                    this.returnObject[key] = returnFieldArry.reverse();
                                  }
                                } else {
                                  //在线外包装工站判断是否达到包规
                                  let innerPackIdQuantity = 0;
                                  this._forEach(this.returnObject['packingList'], (item) => {
                                    innerPackIdQuantity = innerPackIdQuantity + Number(item.standardQuantity);
                                  });
                                  this._forEach(returnFieldArry, (item) => {
                                    if (Number(item.standardQuantity) + innerPackIdQuantity > Number(this.returnObject['standardQuantity'])) {
                                      if (this.returnObject['packingList'].length + returnFieldArry.length > Number(this.returnObject['standardQuantity'])) {
                                        this.$confirm(`${currentRequest.params[0].value}  已经超出包装数量`, '提示', {
                                          confirmButtonText: '确定',
                                          type: 'warning'
                                        });
                                        return;
                                      }
                                    } else {
                                      this.returnObject[key] = returnFieldArry.reverse();
                                    }
                                  });
                                }
                              } else {
                                this.returnObject[key] = returnFieldArry.reverse();
                              }
                            }
                            this.setTableValue(component, this.returnObject[key]);
                            if (repeatValList.length > 0) {
                              let msg = `${currentRequest.params[0].value} ${repeatValList.join('，')} 已经被添加到表格中了，请不要重复添加`;
                              if (verifyDuplicate != undefined) {
                                if (verifyDuplicate.field != currentRequest.params[0].code) {
                                  msg = `${currentRequest.params[0].value}中的${verifyDuplicate.headerName} ${repeatValList.join('，')} 已经被添加到表格中了，请不要重复添加`;
                                }
                              }
                              this.$confirm(msg, '提示', {
                                confirmButtonText: '确定',
                                type: 'warning'
                              });
                              return;
                            }
                          } else if (successItem.apiField.indexOf('{Object[') !== -1) {
                            //通过匹配字段中是否含有{Object[字符，进入增加属性添加表格逻辑
                            let returnFieldList = [];
                            if (returnFieldMap.hasOwnProperty(successItem.componentField)) {
                              //将某一个值添加至查询出来的对象中，再将对象添加进表格中，严格要求返回的对象中必须返回ID进行判断重复
                              returnFieldList = this._get(returnFieldMap, successItem.componentField, []);
                            } else {
                              returnFieldList = [returnFieldMap];
                            }
                            let returnFieldObject = this._get(returnFieldList, '[0]', {});
                            //通过符号[分割
                            let additionSymbollist = successItem.apiField.split('[');
                            let additionAttrNameString = currentRequest.componentField;
                            if (additionSymbollist.length > 1) {
                              //移除字符串末尾的]}符号
                              additionAttrNameString = additionSymbollist[1].substring(0, additionSymbollist[1].length - 2);
                              //若存在同时添加多个属性，则使用逗号,分割
                              let additionAttrNameList = additionAttrNameString.split(',');
                              if (additionAttrNameList.length > 1) {
                                this._forEach(additionAttrNameList, (additionName) => {
                                  returnFieldObject[additionName] = this.returnObject[additionName];
                                });
                              } else {
                                returnFieldObject[additionAttrNameString] = this.returnObject[additionAttrNameString];
                              }
                            }
                            //当配置的数据库返回值为组件的字段加上{}则表示将此记录添加进表格中
                            if (!Array.isArray(this.returnObject[key])) {
                              this.returnObject[key] = new Array();
                            }
                            //获取查询记录的ID
                            let repeatId = this._get(returnFieldObject, 'id', '');
                            if (repeatId) {
                              let repeat = this._filter(this.returnObject[key], (filterItem) => {
                                let filterItemId = this._get(filterItem, 'id', '');
                                return filterItemId === repeatId;
                              });
                              if (repeat.length > 0) {
                                // this.layerFailMsg(`${currentRequest.componentName} 已经被添加到表格中了，请不要重复添加`, additionAttrNameString);
                                this.$confirm(`${currentRequest.componentName} 已经被添加到表格中了，请不要重复添加`, '提示', {
                                  confirmButtonText: '确定',
                                  type: 'warning'
                                });
                                return;
                              } else {
                                this.returnObject[key].unshift(returnFieldObject);
                                this.setTableValue(component, this.returnObject[key]);
                              }
                            } else {
                              this.returnObject[key].unshift(returnFieldObject);
                              this.setTableValue(component, this.returnObject[key]);
                            }
                          } else if (successItem.apiField === '[]') {
                            //当配置的数据库返回值为[] 则表示清空表格
                            if (!Array.isArray(this.returnObject[key])) {
                              this.returnObject[key] = new Array();
                            }
                            this.returnObject[key] = [];
                            this.setTableValue(component, this.returnObject[key]);
                          } else {
                            this.returnObject[key] = val;
                            this.setTableValue(component, val);
                          }
                          if (component.disabledInputName) {
                            if (this.returnObject[key].length > 0 && $('[name=' + component.disabledInputName + ']').val()) {
                              $('[name=' + component.disabledInputName + ']').attr('disabled', true);
                            } else {
                              $('[name=' + component.disabledInputName + ']').attr('disabled', false);
                            }
                          }
                          break;
                        case 'textarea':
                          this.returnObject[key] = val;
                          //表单输入框使用field去查找并赋值
                          this.setFormValue(key, val);
                          break;
                        case 'select':
                          if (Array.isArray(val)) {
                            val = this._map(val, (optionDataItem) => {
                              optionDataItem['optionField'] = optionDataItem[component.optionField];
                              optionDataItem['optionText'] = optionDataItem[component.optionText];
                              return optionDataItem;
                            });
                            this.returnObject[key] = val;
                            this.setSelectValue(component, val);
                          } else {
                            this.$message({
                              type: 'warning',
                              message: '下拉框配置的数据源有误，请检查配置！'
                            });
                          }
                          break;
                        case 'report':
                          if (Array.isArray(val)) {
                            this.returnObject[key] = val;
                            this.setSelecReportValue(component, val);
                          } else {
                            this.$message({
                              type: 'warning',
                              message: '检验报告配置的数据源有误，请检查配置！'
                            });
                          }
                          break;
                        case 'extended-fields':
                          let extendedFieldsList1 = $('#extendedFieldsList').find('input');
                          let extendedFieldsList2 = $('#extendedFieldsList').find('select');
                          let extendedFieldsList = [...extendedFieldsList1, ...extendedFieldsList2];
                          if (successItem.apiField) {
                            let fieldList = successItem.apiField.split(',');
                            this._forEach(extendedFieldsList, (item, index) => {
                              let name = $(item).attr('name');
                              this.setFormValue(name, returnFieldMap[fieldList[index]]);
                            });
                          }
                          break;
                        case 'attribute-copy':
                          let attributeCopyList = $('#attributeCopy').find('input');
                          this._forEach(attributeCopyList, (item) => {
                            this.setFormValue($(item).attr('name'), val);
                          });
                          let childerItem = [];
                          this._forEach($('#attributeCopy')[0].children, (item, index) => {
                            if (index > 1 && $('#attributeCopy')[0].children.length != index + 1) {
                              childerItem.push($(item));
                            }
                          });
                          this._forEach(childerItem, (item) => {
                            $(item).remove();
                          });
                          break;
                        case 'multiple-print':
                          let multiplePrintList = $('#multiplePrint').find('input');
                          this._forEach(multiplePrintList, (item) => {
                            $(item).val(val);
                            // this.setFormValue($(item).attr('name'), val);
                          });
                          let multiplePrintChilderItem = [];
                          this._forEach($('#multiplePrint')[0].children, (item, index) => {
                            if (index > 1 && $('#multiplePrint')[0].children.length != index + 1) {
                              multiplePrintChilderItem.push($(item));
                            }
                          });
                          this._forEach(multiplePrintChilderItem, (item) => {
                            $(item).remove();
                          });
                          break;
                        case 'vehicle':
                          this.returnObject[key] = val;
                          //表单输入框使用field去查找并赋值
                          this.setFormValue(key, val);
                          break;
                        case 'record-item':
                          let recordItemList = $('#recordItemList').find('input');
                          this._forEach(recordItemList, (item) => {
                            this.setFormValue($(item).attr('name'), val);
                          });
                          break;
                        default:
                          break;
                      }
                    } else {
                      //若该字段不存在界面的组件中，则先进行判断是否数组
                      if (key.indexOf('List') !== -1) {
                        let itemName = '{' + currentRequest.componentField + '}';
                        if (successItem.apiField === itemName) {
                          //直接将查询出来的对象添加进表格中
                          let returnFieldList = this._get(returnFieldMap, successItem.componentField, []);
                          let returnFieldObject = this._get(returnFieldList, '[0]', {});
                          //当配置的数据库返回值为组件的字段加上{}则表示将此记录添加进表格中
                          if (!Array.isArray(this.returnObject[key])) {
                            this.returnObject[key] = new Array();
                          }
                          //判断序列号是否重复
                          let repeatVal = this._get(returnFieldObject, currentRequest.componentField, '');
                          //匹配是否重复的主键
                          let keyField = currentRequest.componentField;
                          let repeat = this._filter(this.returnObject[key], (filterItem) => {
                            return filterItem[keyField] === repeatVal;
                          });
                          if (repeat.length > 0) {
                            // this.layerFailMsg(`${currentRequest.componentName} ${repeatVal} 已经被添加到表格中了，请不要重复添加`, currentRequest.componentField);
                            this.$confirm(`${currentRequest.componentName} ${repeatVal} 已经被添加到表格中了，请不要重复添加`, '提示', {
                              confirmButtonText: '确定',
                              type: 'warning'
                            });
                            return;
                          } else {
                            this.returnObject[key].unshift(returnFieldObject);
                          }
                        } else if (successItem.apiField === '[]') {
                          //当配置的数据库返回值为[] 则表示清空表格
                          if (!Array.isArray(this.returnObject[key])) {
                            this.returnObject[key] = new Array();
                          }
                          this.returnObject[key] = [];
                        } else if (key === 'mixPackProductList') {
                          let returnFieldList = this._get(returnFieldMap, successItem.apiField.replace('{', '').replace('}', ''), []);
                          let returnFieldObject = this._get(returnFieldList, '[0]', {});
                          //当配置的数据库返回值为组件的字段加上{}则表示将此记录添加进表格中
                          if (!Array.isArray(this.mixPackProductList)) {
                            this.mixPackProductList = new Array();
                          }
                          //判断序列号是否重复
                          let repeatVal = this._get(returnFieldObject, 'sequenceNumber', '');
                          //匹配是否重复的主键
                          let keyField = 'sequenceNumber';
                          let repeat = this._filter(this.mixPackProductList, (filterItem) => {
                            return filterItem[keyField] === repeatVal;
                          });
                          if (repeat.length > 0) {
                            // this.layerFailMsg(`${currentRequest.componentName} ${repeatVal} 已经被添加到表格中了，请不要重复添加`, currentRequest.componentField);
                            this.$confirm('产品序列号已经被添加到表格中了，请不要重复添加', '提示', {
                              confirmButtonText: '确定',
                              type: 'warning'
                            });
                            return;
                          } else {
                            if (this.mixPackProductList && this.returnObject['standardQuantity']) {
                              let msg = '';
                              if (this.returnObject.isPackWeight) {
                                msg = '扫描的产品序列号已经超出包装数量，请称重封箱';
                              } else {
                                msg = '扫描的产品序列号已经超出包装数量，请封箱';
                              }
                              if (this.mixPackProductList.length + 1 > Number(this.returnObject['standardQuantity'])) {
                                this.$confirm(msg, '提示', {
                                  confirmButtonText: '确定',
                                  type: 'warning'
                                });
                                return;
                              } else {
                                if (this.returnObject.weight) {
                                  returnFieldObject['weight'] = this.returnObject.weight;
                                }
                                this.mixPackProductList.unshift(returnFieldObject);
                                this.mixPackForm.mixPackSequenceNumber = '';
                                setTimeout(() => {
                                  focusInput('mixPackSequenceNumber');
                                }, 500);
                              }
                            }
                          }
                        } else {
                          this.returnObject[key] = val;
                          this.setTableValue(component, val);
                        }
                      } else {
                        if (key.includes('Name') && this.returnObject[key.replace('Name', 'Id')]) {
                          this.setFormValue(key.replace('Name', 'Id'), val);
                        } else {
                          this.returnObject[key] = val;
                        }
                      }
                    }
                  }
                } else if (data.length > 1) {
                  //返回list
                  var returnFieldMap = { ...this._get(res, 'data.data[0]', {}) };
                  //根据在通用数据配置好的输入框Name值来渲染INPUT值或者清空INPUT，若配置的Name值不存在生成的动态表单中则不进行设置空
                  this._forEach(currentRequest.successDoList, (successItem) => {
                    let key = successItem.componentField;
                    let val = returnFieldMap[successItem.apiField];
                    //查询配置的返回信息在UI界面是否存在
                    let component = this._find(this.customForms, { field: key });
                    if (component) {
                      switch (component.dataType) {
                        case 'info-input':
                          this.returnObject[key] = val;
                          //表单输入框使用field去查找并赋值
                          this.setFormValue(key, val);
                          break;
                        case 'card':
                          this.returnObject[key] = val;
                          //卡片使用Id去查找并赋值
                          this.setCardValue(component.key, val);
                          break;
                        case 'table':
                          this.returnObject[key] = val;
                          this.setTableValue(component, val);
                          break;
                        case 'extended-fields':
                          let extendedFieldsList1 = $('#extendedFieldsList').find('input');
                          let extendedFieldsList2 = $('#extendedFieldsList').find('select');
                          let extendedFieldsList = [...extendedFieldsList1, ...extendedFieldsList2];
                          if (successItem.apiField) {
                            let fieldList = successItem.apiField.split(',');
                            this._forEach(extendedFieldsList, (item, index) => {
                              let name = $(item).attr('name');
                              this.setFormValue(name, returnFieldMap[fieldList[index]]);
                            });
                          }
                          break;
                        default:
                          break;
                      }
                    } else {
                      this.returnObject[key] = val;
                    }
                  });
                }
                /*
                          else {
                              if (currentRequest.componentName && this.returnObject[currentRequest.componentField]) {
                                  this.layerFailMsg(`未查询到${currentRequest.componentName}：${this.returnObject[currentRequest.componentField]}的信息！`, currentRequest.componentField);
                                  return;
                              }
                          }*/
              } else {
                //操作类API返回信息
                //根据在通用数据配置好的输入框Name值来渲染INPUT值或者清空INPUT，若配置的Name值不存在生成的动态表单中则不进行设置空
                if (res.data.code === 200) {
                  let msg = res.data.msg;
                  if (currentRequest.componentField === 'sequenceNumberOrBadCode' && this.returnObject.sequenceNumberOrBadCode) {
                    if (msg.includes('不良现象')) {
                      this.returnObject.failureName = msg.split('：')[1];
                      this.setFormValue('failureName', this.returnObject.failureName);
                      selectInput('ngSequenceNumber');
                    } else {
                      this.returnObject.sequenceNumberOrBadCode = '';
                      this.setFormValue('sequenceNumberOrBadCode', this.returnObject.sequenceNumberOrBadCode);
                      selectInput('sequenceNumberOrBadCode');
                    }
                  }
                  this._forEach(currentRequest.successDoList, (successItem) => {
                    let key = successItem.componentField;
                    let val = this._get(res, successItem.apiField, '');
                    //查询配置的返回信息在UI界面是否存在
                    let component = this._find(this.customForms, { field: key });
                    if (component) {
                      switch (component.dataType) {
                        case 'card':
                          this.returnObject[key] = val;
                          //卡片使用Id去查找并赋值
                          this.setCardValue(component.key, val);
                          break;
                        case 'input':
                          this.returnObject[key] = val;
                          //表单输入框使用field去查找并赋值
                          this.setFormValue(key, val);
                          break;
                        case 'input-checkbox':
                          this.returnObject[key] = val;
                          //表单输入框使用field去查找并赋值
                          this.setFormValue(key, val);
                          break;
                        case 'info-input':
                          //提供前端某个字段累计显示功能
                          if (successItem.apiField.indexOf('sum') != -1) {
                            let total = 0;
                            if (successItem.apiField.indexOf('.') != -1) {
                              let fieldArr = successItem.apiField.replace('sum(', '').replace(')', '').split('.');
                              this._forEach(this.returnObject[fieldArr[0]], (item) => {
                                total = Number(total) + Number(item[fieldArr[1]]);
                              });
                              if (key + this.returnObject.workorderStationId != localStorage.beforeTotalFinishedQuantity) {
                                localStorage.removeItem(localStorage.beforeTotalFinishedQuantity);
                              }
                              localStorage.setItem(key + this.returnObject.workorderStationId, total);
                              localStorage.setItem('beforeTotalFinishedQuantity', key + this.returnObject.workorderStationId);
                            } else if (successItem.apiField === 'sum()') {
                              this.returnObject[key] = '';
                              total = '';
                              localStorage.setItem(key + this.returnObject.workorderStationId, this.returnObject[key]);
                            } else {
                              let fieldStr = successItem.apiField.replace('sum(', '').replace(')', '');
                              total = this.returnObject[successItem.componentField]
                                ? Number(this.returnObject[successItem.componentField]) + Number(this.returnObject[fieldStr])
                                : Number(this.returnObject[fieldStr]);
                            }
                            this.returnObject[successItem.componentField] = total;
                            this.setFormValue(key, total);
                          } else if (successItem.apiField.indexOf('deduction') > -1) {
                            if (successItem.apiField.indexOf('-') > -1) {
                              let fieldArr = successItem.apiField.replace('deduction(', '').replace(')', '').split('-');
                              if (this.returnObject[fieldArr[0]]) {
                                this.returnObject[key] = Number(this.returnObject[fieldArr[0]]) - Number(this.returnObject[fieldArr[1]]);
                                this.setFormValue(key, this.returnObject[key]);
                                if (key + this.returnObject.workorderStationId != localStorage.beforeDeductionQuantity) {
                                  localStorage.removeItem(localStorage.beforeDeductionQuantity);
                                }
                                localStorage.setItem(key + this.returnObject.workorderStationId, this.returnObject[key]);
                                localStorage.setItem('beforeDeductionQuantity', key + this.returnObject.workorderStationId);
                              }
                            } else {
                              let field = successItem.apiField.replace('deduction(', '').replace(')', '');
                              if (this.returnObject[field]) {
                                this.returnObject[key] = Number(this.returnObject[key]) - Number(this.returnObject[field]);
                                this.setFormValue(key, this.returnObject[key]);
                                if (key + this.returnObject.workorderStationId != localStorage.beforeDeductionQuantity) {
                                  localStorage.removeItem(localStorage.beforeDeductionQuantity);
                                }
                                localStorage.setItem(key + this.returnObject.workorderStationId, this.returnObject[key]);
                                localStorage.setItem('beforeDeductionQuantity', key + this.returnObject.workorderStationId);
                              }
                            }
                          } else if (successItem.apiField.indexOf('eval') > -1) {
                            let that = this;
                            if (currentRequest.condition === 'sequenceNumberWait != FAIL' && !this.returnObject[key]) {
                              this.returnObject[key] = eval(successItem.apiField.replace('eval(', '').replace(')', ''));
                              this.setFormValue(key, this.returnObject[key]);
                              this.returnObject['sequenceNumberWait'] = '';
                              this.setFormValue('sequenceNumberWait', '');
                            } else {
                              this.returnObject[key] = eval(successItem.apiField.replace('eval(', '').replace(')', ''));
                              this.setFormValue(key, this.returnObject[key]);
                            }
                          } else {
                            this.returnObject[key] = val;
                            //表单输入框使用field去查找并赋值
                            this.setFormValue(key, val);
                          }
                          break;
                        case 'select-data':
                          this.returnObject[key] = val;
                          //表单输入框使用field去查找并赋值
                          this.setFormValue(key, val);
                          break;
                        case 'table':
                          let itemName = '{' + successItem.componentField + '}';
                          if (successItem.apiField === itemName) {
                            //当配置的数据库返回值为组件的字段加上{}则表示将此记录添加进表格中
                            if (!Array.isArray(this.returnObject[key])) {
                              this.returnObject[key] = new Array();
                            }
                            let data = this._get(res, 'data.data', {});
                            this.returnObject[key].unshift(data);
                            this.setTableValue(component, this.returnObject[key]);
                          } else if (successItem.apiField === '[]') {
                            //当配置的数据库返回值为[] 则表示清空表格
                            if (!Array.isArray(this.returnObject[key])) {
                              this.returnObject[key] = new Array();
                            }
                            this.returnObject[key] = [];
                            this.setTableValue(component, this.returnObject[key]);
                            if (this.showMixPackDialog) {
                              this.mixPackForm.mixPackSequenceNumber = '';
                              this.mixPackProductList = [];
                              this.showMixPackDialog = false;
                            }
                          } else if (successItem.apiField.indexOf('remove(') != -1) {
                            //通过符号[分割
                            let additionSymbollist = successItem.apiField.split('(');
                            let additionAttrNameString = currentRequest.componentField;
                            if (additionSymbollist.length > 1) {
                              //移除字符串末尾的})符号
                              additionAttrNameString = additionSymbollist[1].substring(0, additionSymbollist[1].length - 1);
                              let arr = additionAttrNameString.split(',');
                              let tableCloumnField = arr[0];
                              let inputField = arr[1];
                              for (let i = 0; i < this.returnObject[key].length; i++) {
                                if (this.returnObject[key][i][tableCloumnField] === this.returnObject[inputField]) {
                                  this.returnObject[key].splice(i, 1);
                                  this.setTableValue(component, this.returnObject[key]);
                                  break;
                                }
                              }
                            }
                          } else {
                            this.returnObject[key] = val;
                            this.setTableValue(component, val);
                          }
                          if (component.disabledInputName) {
                            if (this.returnObject[key].length === 0) {
                              $('[name=' + component.disabledInputName + ']').attr('disabled', false);
                            }
                          }
                          break;
                        case 'select':
                          if (Array.isArray(val)) {
                            val = this._map(val, (optionDataItem) => {
                              optionDataItem['optionField'] = optionDataItem[component.optionField];
                              optionDataItem['optionText'] = optionDataItem[component.optionText];
                              return optionDataItem;
                            });
                            this.returnObject[key] = val;
                            this.setSelectValue(component, val);
                          } else {
                            this.$message({
                              type: 'warning',
                              message: '下拉框配置的数据源有误，请检查配置！'
                            });
                          }
                          break;
                        case 'report':
                          let returnRemarkList = this._get(res, 'data.data', []);
                          if (!Array.isArray(returnRemarkList)) {
                            this.$message({
                              type: 'warning',
                              message: '获取检验报告备注信息数据有误，请检查配置！'
                            });
                            return;
                          }
                          if (Array.isArray(this.returnObject[key])) {
                            let attributes = this.returnObject[key];
                            // 获取之前测试工站的备注放在检验结果里
                            attributes = attributes.map((attributesItem) => {
                              returnRemarkList.forEach((remarkItem) => {
                                if (attributesItem.code === remarkItem.code && attributesItem.zhCnName === remarkItem.zhCnName) {
                                  attributesItem.checkValue = remarkItem.remark;
                                }
                              });
                              return attributesItem;
                            });
                            this.setSelecReportValue(component, attributes);
                          } else {
                            this.$message({
                              type: 'warning',
                              message: '检验报告配置的数据源有误，请检查配置！'
                            });
                          }
                          break;
                        case 'extended-fields':
                          let extendedFieldsList1 = $('#extendedFieldsList').find('input');
                          let extendedFieldsList2 = $('#extendedFieldsList').find('select');
                          let extendedFieldsList = [...extendedFieldsList1, ...extendedFieldsList2];
                          this._forEach(extendedFieldsList, (item) => {
                            this.setFormValue($(item).attr('name'), val);
                          });
                          break;
                        case 'attribute-copy':
                          let attributeCopyList = $('#attributeCopy').find('input');
                          this._forEach(attributeCopyList, (item) => {
                            this.setFormValue($(item).attr('name'), val);
                          });
                          let childerItem = [];
                          this._forEach($('#attributeCopy')[0].children, (item, index) => {
                            if (index > 1 && $('#attributeCopy')[0].children.length != index + 1) {
                              childerItem.push($(item));
                            }
                          });
                          this._forEach(childerItem, (item) => {
                            $(item).remove();
                          });
                          break;
                        case 'multiple-print':
                          let multiplePrintList = $('#multiplePrint').find('input');
                          this._forEach(multiplePrintList, (item) => {
                            $(item).val(val);
                            // this.setFormValue($(item).attr('name'), val);
                          });
                          let multiplePrintChilderItem = [];
                          this._forEach($('#multiplePrint')[0].children, (item, index) => {
                            if (index > 1 && $('#multiplePrint')[0].children.length != index + 1) {
                              multiplePrintChilderItem.push($(item));
                            }
                          });
                          this._forEach(multiplePrintChilderItem, (item) => {
                            $(item).remove();
                          });
                          break;
                        case 'vehicle':
                          this.returnObject[key] = val;
                          //表单输入框使用field去查找并赋值
                          this.setFormValue(key, val);
                          break;
                        case 'record-item':
                          let recordItemList = $('#recordItemList').find('input');
                          this._forEach(recordItemList, (item) => {
                            this.setFormValue($(item).attr('name'), val);
                          });
                          break;
                        case 'file-button':
                          this.returnObject[key] = val;
                          this.fileList = val;
                        default:
                          break;
                      }
                    } else {
                      this.returnObject[key] = val;
                    }
                  });
                  this.successMsgList.push(res.data.msg);
                } else if (res.data.code === 403) {
                  this.$confirm('主协作人已退出系统，请重新绑定作业工位！', '提示', {
                    confirmButtonText: '确定',
                    type: 'warning'
                  }).then(() => {
                    this.back();
                  });
                } else {
                  if (currentRequest.componentFailTurnToInputName) {
                    selectInput(currentRequest.componentFailTurnToInputName);
                  }
                }
              }
            }

            //通过检查步骤组件上绑定的APIID来判断当前调用的API是否需要映射到检查步骤组件
            let selectedNodeInfo = this._find(this.stationUiList, (dragItem) => {
              let checkStepApiId = this._get(dragItem, 'cfModelAttribute.checkStepApiId', '');
              if (checkStepApiId === currentRequest.id) {
                return true;
              }
            });
            if (selectedNodeInfo) {
              let checkStepId = this._get(selectedNodeInfo, 'cfModelAttribute.id', '');
              let checkStepList = this._get(selectedNodeInfo, 'cfModelAttribute.checkStepList', []);
              let $stepContent = $('#' + checkStepId).find('.step-content');
              $stepContent.empty();
              if (checkStepList.length > 0) {
                let $ps = '';
                this._forEach(checkStepList, (item) => {
                  $ps += `<p class="step-desc text-green"><i class="iconfont el-icon-success"></i>${item.zhCnName}</p>`;
                });
                $stepContent.append($ps);
              }
            }
            //通过判断工站流程中是否存在记录数据节点来判断是否弹出成功提示信息
            // let hasRecordNode = false;
            // if (currentRequest.apiFlowJson) {
            //     let stationFlowJson = JSON.parse(currentRequest.apiFlowJson);
            //     let recordNode = this._find(stationFlowJson.nodeDataArray, { nodeType: 'RECORD' });
            //     hasRecordNode = recordNode ? true : false;
            // }
            //非验证的情况才出现成功提示
            if (this.isShowSuccessMsg && currentRequest.condition != 'SYSTEM_FAIL' && this.successMsgList.length > 0 && requestList.length == count + 1) {
              for (let i = 1; i <= this.successMsgList.length; i++) {
                if (this.successMsgList[this.successMsgList.length - i] != null && this.successMsgList[this.successMsgList.length - i] != '') {
                  this.$message({
                    type: 'success',
                    message: this.successMsgList[this.successMsgList.length - i]
                  });
                  if (currentRequest.componentSuccessVoicePrompt) {
                    showVoiceLog(currentRequest.componentSuccessVoicePrompt);
                  } else {
                    showSuccessLog(this.successMsgList[this.successMsgList.length - i]);
                  }
                  break;
                }
              }
              this.successMsgList = [];
            }

            /**
             * 应悦尔声学需求，组装发生错误后需要解绑序列号上所有子件，所以需要配置API在错误时候调用
             * 当前API是否为失败时调用的API，
             * 是则调用结束后不做任何操作，反之继续判断下一个API响应
             * 若当前API返回成功时：
             * 判断有下一个API响应并且触发条件为失败时，则跳过失败的API顺序执行函数
             * 反之顺序执行函数
             */
            if (currentRequest.condition === 'SYSTEM_FAIL') {
              //由于弹出框本身存在延时聚焦，所以这里的延时需要比错误弹出框还要晚才能跳回到充电盒序列号输入框
              setTimeout(() => {
                selectInput(currentRequest.componentTurnToInputName);
              }, 2050);
            } else {
              let nextIndex = ++count;
              let nextRequest = requestList[nextIndex];
              if (!nextRequest && currentRequest.componentTurnToInputName) {
                let isDisabled = $($('[name=' + currentRequest.componentTurnToInputName + ']')[0]).is(':disabled');
                if (!isDisabled) {
                  selectInput(currentRequest.componentTurnToInputName);
                } else {
                  selectInput(currentRequest.componentField);
                }
              }
              if (nextRequest && nextRequest.condition === 'SYSTEM_FAIL') {
                this.httpRequest(requestList, nextIndex + 1);
              } else {
                this.httpRequest(requestList, nextIndex);
              }
            }
            this.returnObject.weight = '';
          },
          (error) => {
            this.isRequestComplete = true;
            //根据在通用数据配置好的输入框Name值来渲染INPUT值或者清空INPUT，若配置的Name值不存在生成的动态表单中则不进行设置空
            this._forEach(currentRequest.failDoList, (successItem) => {
              let key = successItem.componentField;
              // let val = this._get(error, successItem.apiField, '');
              let val = successItem.apiField;
              //查询配置的返回信息在UI界面是否存在
              let component = this._find(this.customForms, { field: key });
              if (component) {
                switch (component.dataType) {
                  case 'card':
                    this.returnObject[key] = val;
                    //卡片使用Id去查找并赋值
                    this.setCardValue(component.key, val);
                    break;
                  case 'input':
                    this.returnObject[key] = val;
                    //表单输入框使用field去查找并赋值
                    this.setFormValue(key, val);
                    break;
                  case 'textarea':
                    this.returnObject[key] = val;
                    //表单输入框使用field去查找并赋值
                    this.setFormValue(key, val);
                    break;
                  case 'info-input':
                    this.returnObject[key] = val;
                    //表单输入框使用field去查找并赋值
                    this.setFormValue(key, val);
                    break;
                  case 'select-data':
                    this.returnObject[key] = val;
                    //表单输入框使用field去查找并赋值
                    this.setFormValue(key, val);
                    break;
                  case 'table':
                    let itemName = '{' + successItem.componentField + '}';
                    if (successItem.apiField === itemName) {
                      //当配置的数据库返回值为组件的字段加上{}则表示将此记录添加进表格中
                      if (!Array.isArray(this.returnObject[key])) {
                        this.returnObject[key] = new Array();
                      }
                      let data = this._get(error, 'data.data', {});
                      this.returnObject[key].unshift(data);
                      this.setTableValue(component, this.returnObject[key]);
                    } else if (successItem.apiField === '[]') {
                      //当配置的数据库返回值为[] 则表示清空表格
                      if (!Array.isArray(this.returnObject[key])) {
                        this.returnObject[key] = new Array();
                      }
                      this.returnObject[key] = [];
                      this.setTableValue(component, this.returnObject[key]);
                    } else {
                      this.returnObject[key] = val;
                      this.setTableValue(component, val);
                    }
                    break;
                  case 'extended-fields':
                    let extendedFieldsList1 = $('#extendedFieldsList').find('input');
                    let extendedFieldsList2 = $('#extendedFieldsList').find('select');
                    console.log(extendedFieldsList1, extendedFieldsList2);
                    let extendedFieldsList = [...extendedFieldsList1, ...extendedFieldsList2];
                    this._forEach(extendedFieldsList, (item) => {
                      this.setFormValue($(item).attr('name'), val);
                    });
                    break;
                  case 'attribute-copy':
                    let attributeCopyList = $('#attributeCopy').find('input');
                    this._forEach(attributeCopyList, (item) => {
                      this.setFormValue($(item).attr('name'), val);
                    });
                    let childerItem = [];
                    this._forEach($('#attributeCopy')[0].children, (item, index) => {
                      if (index > 1 && $('#attributeCopy')[0].children.length != index + 1) {
                        childerItem.push($(item));
                      }
                    });
                    this._forEach(childerItem, (item) => {
                      $(item).remove();
                    });
                    break;
                  case 'multiple-print':
                    let multiplePrintList = $('#multiplePrint').find('input');
                    this._forEach(multiplePrintList, (item) => {
                      // this.setFormValue($(item).attr('name'), val);
                      $(item).val(val);
                    });
                    let multiplePrintChilderItem = [];
                    this._forEach($('#multiplePrint')[0].children, (item, index) => {
                      if (index > 1 && $('#multiplePrint')[0].children.length != index + 1) {
                        multiplePrintChilderItem.push($(item));
                      }
                    });
                    this._forEach(multiplePrintChilderItem, (item) => {
                      $(item).remove();
                    });
                    break;
                  case 'vehicle':
                    this.returnObject[key] = val;
                    //表单输入框使用field去查找并赋值
                    this.setFormValue(key, val);
                    break;
                  case 'record-item':
                    let recordItemList = $('#recordItemList').find('input');
                    this._forEach(recordItemList, (item) => {
                      this.setFormValue($(item).attr('name'), val);
                    });
                    break;
                  default:
                    break;
                }
              } else {
                this.returnObject[key] = val;
              }
            });

            //通过检查步骤组件上绑定的APIID来判断当前调用的API是否需要映射到检查步骤组件
            let selectedNodeInfo = this._find(this.stationUiList, (dragItem) => {
              let checkStepApiId = this._get(dragItem, 'cfModelAttribute.checkStepApiId', '');
              if (checkStepApiId === currentRequest.id) {
                return true;
              }
            });
            if (selectedNodeInfo) {
              let apiCheckStepStatus = this._get(error, 'data.data', []);
              let checkStepId = this._get(selectedNodeInfo, 'cfModelAttribute.id', '');
              let checkStepList = this._get(selectedNodeInfo, 'cfModelAttribute.checkStepList', []);
              let $stepContent = $('#' + checkStepId).find('.step-content');
              $stepContent.empty();
              if (checkStepList.length > 0) {
                let $ps = '';
                if (apiCheckStepStatus.length > 0) {
                  //接口返回错误之后data中有数据则表示有检查项检查通过
                  this._forEach(checkStepList, (item, index) => {
                    let pStatusHtml = `<p class="step-desc"><i class="iconfont icon-big-circle"></i>${item.zhCnName}</p>`;
                    let apiCheckStepStatusObj = apiCheckStepStatus[index];
                    let apiCheckStepStatusStateCode = this._get(apiCheckStepStatusObj, 'stateCode', 'original');
                    if (apiCheckStepStatusStateCode === 'SYSTEM_SUCCESS') {
                      pStatusHtml = `<p class="step-desc text-green"><i class="iconfont el-icon-success"></i>${item.zhCnName}</p>`;
                    } else if (apiCheckStepStatusStateCode === 'SYSTEM_FAIL') {
                      pStatusHtml = `<p class="step-desc text-red"><i class="iconfont el-icon-error"></i>${item.zhCnName}</p>`;
                    }
                    $ps += pStatusHtml;
                  });
                } else {
                  //data中没有数据则表示第一项就错误了，则所有的都错误
                  this._forEach(checkStepList, (item, index) => {
                    $ps += `<p class="step-desc text-red"><i class="iconfont el-icon-error"></i>${item.zhCnName}</p>`;
                  });
                }
                $stepContent.append($ps);
              }
            }
            if (requestList[count].componentField) {
              this.setFormValue(
                requestList[count].componentField,
                $('[name = ' + requestList[count].componentField + ']')
                  .val()
                  .replace(/(\s*$)/g, '')
              );
            }
            selectInput(requestList[count].componentField);
            if (currentRequest.componentFailTurnToInputName) {
              selectInput(currentRequest.componentFailTurnToInputName);
            }
            if (error.data.msg && error.data.msg != null) {
              let message = error.data.msg;
              if (error.data.msg.includes('\n')) {
                message = error.data.msg.replace(/\n/g, '<br>');
              }
              if (currentRequest.componentFailVoicePrompt) {
                showVoiceLog(currentRequest.componentFailVoicePrompt);
              } else {
                showFailLog(message);
              }
            } else {
              for (let i = 1; i <= this.successMsgList.length; i++) {
                if (this.successMsgList[this.successMsgList.length - i] != null && this.successMsgList[this.successMsgList.length - i] != '') {
                  this.$message({
                    type: 'success',
                    message: this.successMsgList[this.successMsgList.length - i]
                  });
                  showSuccessLog(this.successMsgList[this.successMsgList.length - i]);
                  break;
                }
              }
            }
            /**
             * 应悦尔声学需求，组装发生错误后需要解绑序列号上所有子件，所以需要配置API在失败时候调用
             * 获取到下一个API响应的触发条件为失败时，才执行下一个API响应；
             * 反之不做任务操作
             */
            let nextRequest = requestList[count + 1];
            if (nextRequest && nextRequest.condition === 'SYSTEM_FAIL') {
              this.httpRequest(requestList, count + 1);
            }
            this.returnObject.weight = '';
            //混工单生产时报错选中混工单产品输入框
            if (this.showMixPackDialog) {
              selectInput('mixPackSequenceNumber');
            }
          }
        );
      }
    },

    /**
     * 设置表单的值
     * @param name
     * @param value
     */
    setFormValue(name, value) {
      $('[name=' + name + ']').val(value);
      if (!value) {
        focusInput(name);
      }
    },

    /**
     * 设置卡片的值
     * @param componentId
     * @param value
     */
    setCardValue(componentId, value) {
      $('#' + componentId)
        .find('.card-count')
        .text(value);
    },

    /**
     * 设置表格信息
     * @param component
     * @param value
     */
    setTableValue(component, value) {
      if (Array.isArray(value)) {
        this.refreshTable(component, value);
        if (component.isEnableCache) {
          let setValue = { key: component, tableList: value };
          localStorage.setItem(`${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}`, JSON.stringify(setValue));
        }
      } else {
        this.$message({
          type: 'warning',
          message: '表格配置的数据源有误，请检查配置！'
        });
      }
    },

    /**
     * 刷新表格数据
     * @param component 表格组件
     * @param value 表格body数据
     */
    refreshTable(component, tableList) {
      let $table = $('#' + component.key).find('table');
      $table.find('tbody').empty();
      let trTemplate = '';
      $('#' + component.key)
        .find('.table-length')
        .text(tableList.length);

      this._forEach(tableList, (item, trIndex) => {
        let tdTemplate = '';
        this._forEach(component.columnDefs, (ele) => {
          let value = this._get(item, ele.field, undefined);
          if (ele.field === 'delete') {
            //若存在操作列，则绑定删除事件
            tdTemplate += `<td><button type="button" class="el-button el-button--text el-button--small delete-btn"><i class="el-icon-delete"></i><span>删除</span></button></td>`;
          } else if (ele.field === 'workOrderNo' && item['workOrderNo'] && item['workOrderNo'] != this.returnObject.workOrderNo) {
            tdTemplate += '<td class="mixedWorkOrder">' + value + '</td>';
          } else {
            if (value !== undefined) {
              if (ele.cellRenderer) {
                let cellRenderer = eval(ele.cellRenderer);
                tdTemplate += '<td>' + cellRenderer(value) + '</td>';
              } else {
                tdTemplate += '<td>' + value + '</td>';
              }
            } else {
              tdTemplate += '<td></td>';
            }
          }
        });
        trTemplate = '<tr data-index=' + trIndex + '>' + tdTemplate + '</tr>';
        $table.find('tbody').append(trTemplate);
      });
      $('.mixedWorkOrder').parents('tr').css('background', 'red');
      //若存在操作列，则绑定删除事件
      $('.delete-btn').on('click', (event) => {
        let trIndex = $(event.target).parents('tr').attr('data-index');
        this.returnObject[component.field].splice(Number(trIndex), 1);
        this.refreshTable(component, this.returnObject[component.field]);
        if (component.isEnableCache) {
          let setValue = { key: component, tableList: this.returnObject[component.field] };
          localStorage.setItem(`${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}`, JSON.stringify(setValue));
        }
        if (this.returnObject[component.field].length === 0 && component.disabledInputName) {
          $('[name=' + component.disabledInputName + ']').attr('disabled', false);
        }
      });
    },

    /**
     * 设置下拉框信息
     * @param component
     * @param value
     */
    setSelectValue(component, value) {
      if (Array.isArray(value)) {
        this.refreshSelect(component, value);
      } else {
        this.$message({
          type: 'error',
          message: '下拉框配置的数据源有误，请检查配置！'
        });
      }
    },

    /**
     * 刷新下拉框数据
     * @param msg
     * @param inputName
     */
    refreshSelect(component, value) {
      console.log(value);
      let $select = $('#' + component.key).find('select');
      $select.empty();
      let optionTemplate = '';
      this._forEach(value, (item) => {
        optionTemplate += `<option value="${item.optionField}">${item.optionText}</option>`;
      });
      $select.append('<option value="" selected="selected">请选择</option>');
      $select.append(optionTemplate);
    },

    /**
     * 回车事件函数构造
     */
    onEnterHttpRequestInit() {
      this.isShowSuccessMsg = true;
      let enterRequestList = [];
      this._forEach(this.stationUiList, (item) => {
        this._forEach(item.cfActionList, (actionItem) => {
          if (actionItem.actionType === 'enter') {
            actionItem.commonDataList = this._map(actionItem.commonDataList, (commonDataItem, index) => {
              commonDataItem['componentId'] = item.cfModelAttribute.id;
              commonDataItem['componentName'] = item.cfModelAttribute.labelName;
              commonDataItem['componentField'] = item.cfModelAttribute.field;
              commonDataItem['componentType'] = item.cfModelAttribute.dataType;
              commonDataItem['actionType'] = actionItem.actionType;
              commonDataItem['componentTurnToInputName'] = item.cfModelAttribute.turnToInputName;
              commonDataItem['componentSuccessVoicePrompt'] = item.cfModelAttribute.successVoicePrompt;
              commonDataItem['componentFailVoicePrompt'] = item.cfModelAttribute.failVoicePrompt;
              if (
                actionItem.commonDataList.length === index + 1 ||
                commonDataItem.condition === 'SYSTEM_FAIL' ||
                commonDataItem.condition === 'productList.length===standardQuantity' ||
                commonDataItem.condition === 'packingList.length===standardQuantity' ||
                commonDataItem.condition === 'carrierProductQuantity>=standardQuantity' ||
                commonDataItem.condition === 'packWeight'
              ) {
                // commonDataItem['componentTurnToInputName'] = item.cfModelAttribute.turnToInputName;
                commonDataItem['componentFailTurnToInputName'] = item.cfModelAttribute.failTurnToInputName;
                commonDataItem['componentNoApiTurnToInputName'] = item.cfModelAttribute.noApiTurnToInputName;
                commonDataItem['turnToExpression'] = item.cfModelAttribute.turnToExpression;
              }

              return commonDataItem;
            });
            actionItem['componentId'] = item.cfModelAttribute.id;
            actionItem['componentName'] = item.cfModelAttribute.labelName;
            actionItem['componentField'] = item.cfModelAttribute.field;
            actionItem['componentTurnToInputName'] = item.cfModelAttribute.turnToInputName;
            actionItem['componentFailTurnToInputName'] = item.cfModelAttribute.failTurnToInputName;
            actionItem['componentNoApiTurnToInputName'] = item.cfModelAttribute.noApiTurnToInputName;
            actionItem['turnToExpression'] = item.cfModelAttribute.turnToExpression;
            actionItem['componentType'] = item.cfModelAttribute.dataType;
            actionItem['componentNoApiTurnToInputIsMsg'] = item.cfModelAttribute.noApiTurnToInputIsMsg;
            actionItem['regexp'] = item.cfModelAttribute.regexp;
            actionItem['beforeRequestData'] = item.cfModelAttribute.beforeRequestData;
            enterRequestList.push(actionItem);
          }
        });
      });
      console.log('-------------带回车事件的组件-------------');
      console.log(enterRequestList);
      this._forEach(enterRequestList, (item) => {
        if (item.componentType === 'input' || item.componentType === 'vehicle' || item.componentType === 'select-data' || item.componentType === 'input-checkbox') {
          let dragDom = document.getElementById(item.componentId);
          let input = dragDom.getElementsByTagName('INPUT')[0];
          input.addEventListener('keypress', (event) => {
            if ($(event) && $(event)[0].keyCode === 13) {
              console.log(item.componentName);
              this.returnObject[item.componentField] = $(event.target).val();
              if (this.returnObject[item.componentField] === 'FAIL' && item.beforeRequestData.length > 0) {
                this.beforeRequestData = item.beforeRequestData;
                let isSelect = false;
                let selectName = '';
                this._forEach(this.beforeRequestData, (item) => {
                  if (!item.isDisabled && !isSelect) {
                    isSelect = true;
                    selectName = item.code;
                  }
                  if (item.defaultValue) {
                    if (item.defaultValue.indexOf('{') != -1) {
                      let code = item.defaultValue.replace('{', '').replace('}', '');
                      console.log(code);
                      this.returnObject[item.code] = this.returnObject[code];
                    }
                  }
                  if (item.isReqired) {
                    this.beforeRequestRules[item.code] = [{ required: true, message: `请输入${item.name}`, trigger: 'submit' }];
                  }
                });
                console.log(this.beforeRequestRules);
                this.showBeforeRequestDialog = true;
                setTimeout(() => {
                  focusInput(selectName);
                }, 500);
                this.httpRequestParams = {
                  requestList: item.commonDataList,
                  count: 0
                };
                return;
              }
              let reg = eval(item.regexp);
              if (item.regexp && !reg.test(this.returnObject[item.componentField])) {
                this.$message.warning(`当前输入的${item.componentName}不符合设定的表达式，请联系管理员！`);
                return;
              }
              item.commonDataList = this._filter(item.commonDataList, (item) => {
                return item.id;
              });
              if (item.commonDataList.length === 0) {
                if (item.componentNoApiTurnToInputName) {
                  selectInput(item.componentNoApiTurnToInputName);
                }
                if (item.componentNoApiTurnToInputIsMsg) {
                  showSuccessLog('操作成功!');
                }
              } else {
                this.inProgressField = item.componentField;
                this.httpRequest(item.commonDataList, 0);
              }
            }
          });
        }
      });
    },
    /**
     * 点击事件函数构造
     */
    onClickHttpRequestInit() {
      this.isShowSuccessMsg = true;
      let clickRequestList = [];
      this._forEach(this.stationUiList, (item) => {
        console.log(item);
        // if (item.cfModelAttribute.isSupportMixPack) {
        //   if (item.cfModelAttribute.dataType === 'button') {
        //     let dragDom = document.getElementById(item.cfModelAttribute.id);
        //     let button = dragDom.getElementsByTagName('BUTTON')[0];
        //     button.addEventListener('click', (event) => {
        //       this.showMixPackDialog = true;
        //       this.productInfoList = [];
        //       this.$nextTick(() => {
        //         selectInput('sequenceNumber');
        //       });
        //       this.mixPackForm.standardQuantity = this.returnObject.standardQuantity;
        //       this.mixPackField = item.cfModelAttribute.mixPackField;
        //       this.productInfoList = this.returnObject[item.cfModelAttribute.mixPackField] ? this.returnObject[item.cfModelAttribute.mixPackField] : [];
        //     });
        //   }
        // }
        this._forEach(item.cfActionList, (actionItem) => {
          if (actionItem.actionType === 'click' || actionItem.actionType === 'select-data') {
            actionItem.commonDataList = this._map(actionItem.commonDataList, (commonDataItem, index) => {
              commonDataItem['componentId'] = item.cfModelAttribute.id;
              commonDataItem['componentName'] = item.cfModelAttribute.labelName;
              commonDataItem['componentField'] = item.cfModelAttribute.field;
              commonDataItem['componentType'] = item.cfModelAttribute.dataType;
              commonDataItem['actionType'] = actionItem.actionType;

              // if (actionItem.commonDataList.length === index + 1) {
              commonDataItem['componentTurnToInputName'] = item.cfModelAttribute.turnToInputName;
              commonDataItem['turnToExpression'] = item.cfModelAttribute.turnToExpression;
              // }
              commonDataItem['componentFailTurnToInputName'] = item.cfModelAttribute.failTurnToInputName;
              commonDataItem['componentNoApiTurnToInputName'] = item.cfModelAttribute.noApiTurnToInputName;
              commonDataItem['isSupportMixPack'] = item.cfModelAttribute.isSupportMixPack;
              commonDataItem['mixPackField'] = item.cfModelAttribute.mixPackField;

              return commonDataItem;
            });
            actionItem['componentId'] = item.cfModelAttribute.id;
            actionItem['componentName'] = item.cfModelAttribute.labelName;
            actionItem['componentField'] = item.cfModelAttribute.field;
            actionItem['componentTurnToInputName'] = item.cfModelAttribute.turnToInputName;
            actionItem['componentNoApiTurnToInputName'] = item.cfModelAttribute.noApiTurnToInputName;
            actionItem['turnToExpression'] = item.cfModelAttribute.turnToExpression;
            actionItem['componentType'] = item.cfModelAttribute.dataType;
            actionItem['componentDisplayOrHideModules'] = item.cfModelAttribute.displayOrHideModules;
            actionItem['isSupportMixPack'] = item.cfModelAttribute.isSupportMixPack;
            actionItem['mixPackField'] = item.cfModelAttribute.mixPackField;
            actionItem['isOpenDialogConfig'] = item.cfModelAttribute.isOpenDialogConfig;
            actionItem['dialogUiConfig'] = item.cfModelAttribute.dialogUiConfig;
            clickRequestList.push(actionItem);
          }
        });
      });
      console.log('-------------带点击事件的组件-------------');
      console.log(clickRequestList);
      this._forEach(clickRequestList, (item) => {
        if (item.componentType === 'button') {
          let dragDom = document.getElementById(item.componentId);
          let button = dragDom.getElementsByTagName('BUTTON')[0];
          button.addEventListener('click', (event) => {
            //判断如果按钮配置了弹窗
            if (item.isOpenDialogConfig) {
              this.statiouiDialogConfig = item.dialogUiConfig;
              this.showDialogUi = true;
            } else {
              this.returnObject[item.componentField] = $(event.target).val();
              item.commonDataList = this._filter(item.commonDataList, (item) => {
                return item.id;
              });
              if (item.isSupportMixPack) {
                this.showMixPackDialog = true;
                this.mixPackProductList = [];
                this.$nextTick(() => {
                  selectInput('mixPackSequenceNumber');
                });
                this.mixPackForm.standardQuantity = this.returnObject.standardQuantity;
                this.mixPackField = item.mixPackField;
                this.mixPackProductList = this.returnObject[item.mixPackField] ? this.returnObject[item.mixPackField] : [];
                this.mixPackHttpRequestList = item.commonDataList;
                return;
              }
              //判断是否需要包装称重
              if (
                item.componentField === 'sealing' &&
                this.returnObject.isPackWeight &&
                (this.returnObject.weightPoint === 'SEALING' || this.returnObject.weightPoint === 'BOTH')
              ) {
                this.showPackWeightDialog = true;
                this.packWeightInfo.standardWeight = this.returnObject.sealingStandardWeight;
                this.packWeightInfo.weightUpper = this.returnObject.maxWeight2;
                this.packWeightInfo.weightLower = this.returnObject.minWeight2;
                setTimeout(() => {
                  focusInput('weight');
                }, 500);
                this.commonDataList = item.commonDataList;
                this.isAutomatic = false;
              } else {
                if (item.commonDataList.length === 0) {
                  if (item.componentNoApiTurnToInputName) {
                    selectInput(item.componentNoApiTurnToInputName);
                  }
                } else {
                  this.returnObject.weight = 0;
                  this.httpRequest(item.commonDataList, 0);
                }
              }
              if (item.componentDisplayOrHideModules) {
                let parent = $(`#${item.componentDisplayOrHideModules}`).parent();
                if ($(`#${item.componentDisplayOrHideModules}`).is(':hidden')) {
                  $(parent).css('display', 'block');
                } else {
                  $(parent).css('display', 'none');
                }
              }
            }
          });
        }
      });
    },

    /**
     * 空格键提交事件构造函数
     */
    onCtrlHttpRequestInit() {
      this.isShowSuccessMsg = true;
      let ctrlRequestList = [];
      this._forEach(this.stationUiList, (item) => {
        this._forEach(item.cfActionList, (actionItem) => {
          if (actionItem.actionType === 'space') {
            actionItem.commonDataList = this._map(actionItem.commonDataList, (commonDataItem, index) => {
              commonDataItem['componentId'] = item.cfModelAttribute.id;
              commonDataItem['componentName'] = item.cfModelAttribute.labelName;
              commonDataItem['componentField'] = item.cfModelAttribute.field;
              commonDataItem['componentType'] = item.cfModelAttribute.dataType;
              commonDataItem['actionType'] = actionItem.actionType;
              if (
                actionItem.commonDataList.length === index + 1 ||
                commonDataItem.condition === 'SYSTEM_FAIL' ||
                commonDataItem.condition === 'productList.length===standardQuantity' ||
                commonDataItem.condition === 'packingList.length===standardQuantity' ||
                commonDataItem.condition === 'carrierProductQuantity>=standardQuantity' ||
                commonDataItem.condition === 'packWeight'
              ) {
                commonDataItem['componentTurnToInputName'] = item.cfModelAttribute.turnToInputName;
                commonDataItem['componentFailTurnToInputName'] = item.cfModelAttribute.failTurnToInputName;
                commonDataItem['componentNoApiTurnToInputName'] = item.cfModelAttribute.noApiTurnToInputName;
                commonDataItem['turnToExpression'] = item.cfModelAttribute.turnToExpression;
              }

              return commonDataItem;
            });
            actionItem['componentId'] = item.cfModelAttribute.id;
            actionItem['componentName'] = item.cfModelAttribute.labelName;
            actionItem['componentField'] = item.cfModelAttribute.field;
            actionItem['componentTurnToInputName'] = item.cfModelAttribute.turnToInputName;
            actionItem['componentFailTurnToInputName'] = item.cfModelAttribute.failTurnToInputName;
            actionItem['componentNoApiTurnToInputName'] = item.cfModelAttribute.noApiTurnToInputName;
            actionItem['turnToExpression'] = item.cfModelAttribute.turnToExpression;
            actionItem['componentType'] = item.cfModelAttribute.dataType;
            ctrlRequestList.push(actionItem);
          }
        });
      });
      console.log('-------------带空格事件的组件-------------');
      console.log(ctrlRequestList);
      this._forEach(ctrlRequestList, (item) => {
        if (item.componentType === 'textarea') {
          let dragDom = document.getElementById(item.componentId);
          let input = dragDom.getElementsByTagName('TEXTAREA')[0];
          input.addEventListener('keypress', (event) => {
            if ($(event) && $(event)[0].keyCode === 32) {
              console.log(item.componentName);
              this.returnObject[item.componentField] = $(event.target).val();
              item.commonDataList = this._filter(item.commonDataList, (item) => {
                return item.id;
              });
              if (item.commonDataList.length === 0) {
                selectInput(item.componentNoApiTurnToInputName);
              } else {
                this.inProgressField = item.componentField;
                this.httpRequest(item.commonDataList, 0);
              }
              event.preventDefault();
            }
          });
        }
      });
    },

    /**
     * 记录项回车跳转事件构造
     */
    onRecordItemEnter() {
      this._forEach(this.stationUiList, (item) => {
        if (item.cfModelAttribute.dataType === 'record-item') {
          this._forEach(item.cfModelAttribute.recordItem, (recordItem) => {
            if (recordItem.turnToInputName) {
              let input = document.getElementsByName(recordItem.headerFile)[0];
              input.addEventListener('keypress', (event) => {
                if ($(event) && $(event)[0].key === 'Enter') {
                  selectInput(recordItem.turnToInputName);
                }
              });
            }
          });
        } else if (item.cfModelAttribute.dataType === 'extended-fields') {
          this._forEach(item.cfModelAttribute.extendedFields, (extendedFields) => {
            if (extendedFields.turnToInputName) {
              let input = document.getElementsByName(extendedFields.field)[0];
              input.addEventListener('keypress', (event) => {
                if ($(event) && $(event)[0].key === 'Enter') {
                  selectInput(extendedFields.turnToInputName);
                }
              });
            }
          });
        }
      });
    },

    /**
     * 测试结果change事件
     */
    eventResultChange() {
      let isRadio = false;
      let radioName = '';
      this._forEach(this.stationUiList, (item, index) => {
        if (item.cfModelAttribute.dataType === 'radio' && item.cfModelAttribute.field === 'eventResult') {
          isRadio = true;
          radioName = item.cfModelAttribute.field;
        }
      });
      if (isRadio) {
        $(`input[type=radio][name=${radioName}]`).on('change', () => {
          for (let i = 0; i < this.stationUiList.length; i++) {
            if (
              this.stationUiList[i].cfModelAttribute.dataType === 'input' ||
              this.stationUiList[i].cfModelAttribute.dataType === 'select-data' ||
              this.stationUiList[i].cfModelAttribute.dataType === 'textarea'
            ) {
              this.setFormValue(this.stationUiList[i].cfModelAttribute.field, '');
            }
          }
          selectInput('sequenceNumber');
        });
      }
    },

    /**
     * 打开打印机选择模态框
     */
    openPrinterModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'printerModal';
      this.tableOption = {
        modalTitle: '选择打印机（双击进行选择）',
        url: '/api/mes-product/ems-equipment/page?type=PRINTER',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '打印机名称',
            prop: 'name',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          },
          {
            label: '打印机编码',
            prop: 'code',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          }
        ]
      };
    },

    /**
     * 打开多打印机选择模态框
     */
    openMultiplePrinterModal(index) {
      this.multiplePrintIndex = index;
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'multiplePrinterModal';
      this.tableOption = {
        modalTitle: '选择打印机（双击进行选择）',
        url: '/api/mes-product/ems-equipment/page?type=PRINTER',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '打印机名称',
            prop: 'name',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          },
          {
            label: '打印机编码',
            prop: 'code',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          }
        ]
      };
    },

    /**
     * 打开标签模版选择模态框
     */
    openLabelTemplateModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'labelTemplateModal';
      this.tableOption = {
        modalTitle: '选择标签模版（双击进行选择）',
        url: '/api/mes-admin/labeltemplate/page?status=1',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '标签名称',
            prop: 'fileName',
            search: true
          },
          {
            label: '标签代码',
            prop: 'code',
            search: true
          },
          {
            label: '版本名称',
            prop: 'revision'
          },
          {
            label: '缩略图',
            prop: 'thumbnailUrl'
          },
          {
            label: '打印标签',
            prop: 'fileUrl'
          }
        ]
      };
    },

    /**
     * 打开多个标签模版选择模态框
     */
    openMultipleLabelTemplateModal(index) {
      this.multipleLabelTemplateIndex = index;
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'multipleLabelTemplateModal';
      this.tableOption = {
        modalTitle: '选择标签模版（双击进行选择）',
        url: '/api/mes-admin/labeltemplate/page?status=1',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '标签名称',
            prop: 'fileName',
            search: true
          },
          {
            label: '标签代码',
            prop: 'code',
            search: true
          },
          {
            label: '版本名称',
            prop: 'revision'
          },
          {
            label: '缩略图',
            prop: 'thumbnailUrl'
          },
          {
            label: '打印标签',
            prop: 'fileUrl'
          }
        ]
      };
    },

    /**
     * 打开序列号规则选择模态框
     */
    openSequenceDefineModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'sequenceDefineModal';
      this.tableOption = {
        modalTitle: '选择序列号规则（双击进行选择）',
        url: '/api/mes-admin/sequencedefinition/page?type=material',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '规则名称',
            prop: 'name',
            search: true
          },
          {
            label: '规则编码',
            prop: 'code',
            search: true
          },
          {
            label: '序列号规则',
            prop: 'sequenceNoFormat',
            labelslot: true
          }
        ]
      };
    },

    /**
     * 打开维修代码选择模态框
     */
    openMaintenanceCodeModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'maintenanceCodeModal';
      this.tableOption = {
        modalTitle: '选择维修代码（双击进行选择）',
        url: '/api/mes-product/mro-dict/page?dictType=BAD_REPAIRE_CODE',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '维修代码',
            prop: 'code',
            search: true
          },
          {
            label: '维修动作',
            prop: 'name',
            search: true
          }
        ]
      };
    },
    /**
     * 打开用户选择模态框
     */
    openUserInfoCommonModal() {
      this.modalName = 'registryByName';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择不良登记人员信息（双击进行选择）',
        url: '/api/blade-system/user/page',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '用户姓名',
            prop: 'realName',
            search: true,
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '所属部门',
            prop: 'deptName',
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '职务',
            prop: 'postName'
          },
          {
            label: '用户平台',
            prop: 'userTypeName'
          }
        ]
      };
    },
    /**
     * 打开不良现象模态框
     */
    openFailureModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'failureModal';
      this.tableOption = {
        modalTitle: '选择不良现象（双击进行选择）',
        url: `/api/mes-product/mro-dict/page?dictType=BAD_PHENOMENON`,
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '不良现象名称',
            prop: 'name',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          },
          {
            label: '不良现象编码',
            prop: 'code',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          }
        ]
      };
    },

    /**
     * 打开多不良代码选择模态框
     */
    openAttributeCopyFailureModal(index) {
      this.attributeCopyIndex = index;
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'attributeCopyFailureModal';
      this.tableOption = {
        modalTitle: '选择不良现象（双击进行选择）',
        url: `/api/mes-product/mro-dict/page?dictType=BAD_PHENOMENON`,
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '不良现象名称',
            prop: 'name',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          },
          {
            label: '不良现象编码',
            prop: 'code',
            searchLabelWidth: 130,
            searchSpan: 8,
            search: true
          }
        ]
      };
    },

    /**
     * 打开包规模态框组件
     */
    openPackTypeModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'packTypeModal';
      this.tableOption = {
        modalTitle: '选择包规（双击进行选择）',
        url: '/api/blade-system/dict/dictionary?code=PACK_SPECIFICATION',
        isPage: false,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '包规名称',
            prop: 'dictValue',
            search: true
          },
          {
            label: '包装数量',
            prop: 'dictKey',
            search: true
          }
        ]
      };
    },

    /*
     * 不良代码选择框
     */
    openFailureCommonModal() {
      this.$refs.commonModalTemplate.showModal();
      this.modalName = 'failureCode';
      this.tableOption = {
        modalTitle: '选择不良现象代码信息（双击进行选择）',
        url: '/api/mes-product/mro-dict/page?dictType=BAD_PHENOMENON',
        isPage: true,
        index: false,
        rowSelectionType: 'mutiple',
        searchLabelWidth: 100,
        columnDefs: [
          {
            label: '不良现象代码',
            prop: 'code',
            search: true,
            row: true,
            span: 24,
            rules: [
              {
                required: true,
                message: '请输入不良现象代码',
                trigger: 'blur'
              }
            ]
          },
          {
            label: '不良现象',
            prop: 'name',
            search: true,
            row: true,
            span: 24,
            rules: [
              {
                required: true,
                message: '请输入不良现象',
                trigger: 'blur'
              }
            ]
          }
          // {
          //   label: '工序',
          //   prop: 'workstationRouteCode',
          //   row: true,
          //   type: 'select',
          //   hide: true,
          //   search: true,
          //   dicUrl: '/api/mes-product/apaasworkstation/workstation/list',
          //   props: {
          //     label: 'name',
          //     value: 'code'
          //   },
          //   rules: [
          //     {
          //       required: true,
          //       message: '请选择不良工序',
          //       trigger: 'blur'
          //     }
          //   ]
          // },
          // {
          //   label: '工序',
          //   prop: 'stationName',
          // }
        ]
      };
    },

    /**
     * 公共模态框选中的值
     */
    getSelectedRows(rowData) {
      switch (this.modalName) {
        case 'packTypeModal':
          this.returnObject.standardQuantity = this._get(rowData, 'dictKey', '');
          this.returnObject.standardQuantityName = this._get(rowData, 'dictValue', '') + '--' + this.returnObject.standardQuantity;
          this.setFormValue('standardQuantity', this.returnObject.standardQuantityName);
          let dragItem = this._find(this.customForms, { field: 'standardQuantity' });
          this.setCardValue(this._get(dragItem, 'key', ''), this.returnObject.standardQuantity);
          focusInput('sequenceNumber');
          break;
        case 'failureModal':
          this.returnObject[this.openModalInputName] = this._get(rowData, 'code', '');
          let obj = this._find(this.customForms, { field: 'failureName' });
          if (obj != undefined) {
            this.returnObject.failureName = this._get(rowData, 'name', '');
            this.setFormValue(this.openModalInputName, this._get(rowData, 'code', ''));
            this.setFormValue('failureName', this._get(rowData, 'name', ''));
          } else {
            this.setFormValue(this.openModalInputName, this._get(rowData, 'name', ''));
          }
          break;
        case 'attributeCopyFailureModal':
          $($('#attributeCopy').find('.failureCode')[this.attributeCopyIndex]).find('input').val(this._get(rowData, 'code', ''));
          break;
        case 'printerModal':
          this.returnObject[this.openModalInputName] = this._get(rowData, 'id', '');
          this.setFormValue(this.openModalInputName, this._get(rowData, 'name', ''));
          let printIdInfo = this._find(this.customForms, { field: this.openModalInputName });
          if (printIdInfo.isCachePrintInfo) {
            localStorage.setItem(
              `${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}_printers`,
              JSON.stringify({ [this.openModalInputName]: this._get(rowData, 'id', ''), printName: this._get(rowData, 'name', '') })
            );
          }
          break;
        case 'labelTemplateModal':
          this.returnObject[this.openModalInputName] = this._get(rowData, 'id', '');
          this.setFormValue(this.openModalInputName, this._get(rowData, 'fileName', ''));
          let labelTemplateInfo = this._find(this.customForms, { field: this.openModalInputName });
          if (labelTemplateInfo.isCachePrintInfo) {
            localStorage.setItem(
              `${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}_labelTemplate`,
              JSON.stringify({ [this.openModalInputName]: this._get(rowData, 'id', ''), labelTemplateName: this._get(rowData, 'fileName', '') })
            );
          }
          break;
        case 'sequenceDefineModal':
          this.returnObject[this.openModalInputName] = this._get(rowData, 'id', '');
          this.setFormValue(this.openModalInputName, this._get(rowData, 'name', ''));
          break;
        case 'multiplePrinterModal':
          $($('#multiplePrint').find('.print')[this.multiplePrintIndex]).find('input').val(this._get(rowData, 'name', ''));
          let multiplePrinterInfo = this._find(this.customForms, { field: 'extraPrint' });
          if (this.extraPrint[this.multiplePrintIndex]) {
            this.extraPrint[this.multiplePrintIndex].printId = this._get(rowData, 'id', '');
            this.multiplePrinterInfo[this.multiplePrintIndex].printId = this._get(rowData, 'id', '');
            this.multiplePrinterInfo[this.multiplePrintIndex].printName = this._get(rowData, 'name', '');
          } else {
            this.extraPrint.push({ printId: this._get(rowData, 'id', '') });
            this.multiplePrinterInfo.push({ printId: this._get(rowData, 'id', ''), printName: this._get(rowData, 'name', '') });
          }
          if (multiplePrinterInfo.isCachePrintInfo) {
            localStorage.setItem(
              `${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}_multiplePrinterInfo`,
              JSON.stringify(this.multiplePrinterInfo)
            );
          }
          break;
        case 'multipleLabelTemplateModal':
          $($('#multiplePrint').find('.labelTemplate')[this.multipleLabelTemplateIndex]).find('input').val(this._get(rowData, 'fileName', ''));
          let multipleLabelTemplateInfo = this._find(this.customForms, { field: 'extraPrint' });
          if (this.extraPrint[this.multipleLabelTemplateIndex]) {
            this.extraPrint[this.multipleLabelTemplateIndex].labelTemplateId = this._get(rowData, 'id', '');
            this.multiplePrinterInfo[this.multipleLabelTemplateIndex].labelTemplateId = this._get(rowData, 'id', '');
            this.multiplePrinterInfo[this.multipleLabelTemplateIndex].labelTemplateName = this._get(rowData, 'fileName', '');
          } else {
            this.extraPrint.push({ labelTemplateId: this._get(rowData, 'id', '') });
            this.multiplePrinterInfo.push({ labelTemplateId: this._get(rowData, 'id', ''), labelTemplateName: this._get(rowData, 'fileName', '') });
          }
          if (multipleLabelTemplateInfo.isCachePrintInfo) {
            localStorage.setItem(
              `${this.returnObject.workOrderNo}_${this.returnObject.routeName}_${this.returnObject.stationName}_multiplePrinterInfo`,
              JSON.stringify(this.multiplePrinterInfo)
            );
          }
          break;
        case 'maintenanceCodeModal':
          this.returnObject[this.openModalInputName] = this._get(rowData, 'code', '');
          this.setFormValue(this.openModalInputName, this._get(rowData, 'name', ''));
          break;
        case 'failureCode':
          this.failureInfoDic = this._uniqWith([...this.failureInfoDic, ...rowData], (arrVal, othVal) => {
            return arrVal.id === othVal.id;
          });
          this.failureInfoForm = this.failureInfoDic.map((item) => item.code);
          break;
        case 'registryByName':
          this.failureRegisterForm.registryBy = this._get(rowData, 'id', '');
          this.failureRegisterForm.registryByName = this._get(rowData, 'name', '');
          break;
        default:
          break;
      }
    },

    /**
     * 打开员工登记信息
     */
    openRegister() {
      this.isShowDialog = true;
      this.$nextTick(() => {
        focusInput('registerCode');
      });
    },

    /**
     * 员工登记
     */
    register() {
      if (!this.registerInfoForm.code) {
        this.$message({
          type: 'warning',
          message: '员工编码不能为空！'
        });
        return;
      }
      checkUserCode(this.registerInfoForm.code).then(
        (res) => {
          let userInfo = this._get(res, 'data.data', {});
          let obj = {
            routeId: this.returnObject.routeStationId,
            userId: userInfo.id
          };
          checkSkill(obj).then(
            (res) => {
              let params = {
                operator: userInfo.id,
                operatorName: userInfo.name,
                status: 1,
                workorderStationId: this.returnObject.workorderStationId
              };
              collaborativeOperation(params).then(
                (res) => {
                  this.registerInfoForm.code = '';
                  this.getRegisterInfoList();
                },
                (error) => {
                  selectInput('registerCode');
                }
              );
            },
            (error) => {
              selectInput('registerCode');
            }
          );
        },
        (error) => {
          selectInput('registerCode');
        }
      );
    },

    /**
     * 查询协同作业人员
     */
    getRegisterInfoList() {
      this.registerName = '';
      getcooperatorList(this.returnObject.workorderStationId).then(
        (res) => {
          this.registerInfoList = this._get(res, 'data.data', []);
          this._forEach(this.registerInfoList, (item) => {
            if (this.registerName === '') {
              this.registerName = item.cooperatorName;
            } else {
              this.registerName = `${this.registerName}/${item.cooperatorName}`;
            }
          });
        },
        (error) => {
          this.registerInfoList = [];
        }
      );
    },

    /**
     * 退出协同
     */
    registerInfoRowDel(row) {
      this.$confirm('确定退出协同作业?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let params = {
          id: row.id,
          operator: row.operator,
          operatorName: row.cooperatorName,
          status: 2,
          workorderStationId: this.returnObject.workorderStationId
        };
        collaborativeOperation(params).then(() => {
          this.getRegisterInfoList();
        });
      });
    },

    /**
     * 返回工站作业页面
     */
    back() {
      let isLineLogin = localStorage.getItem('isLineLogin') ? localStorage.getItem('isLineLogin') : 'true';
      if (isLineLogin === 'true') {
        this.$router.replace('/wel/index');
      } else {
        this.$router.replace('/product/station-operation');
      }
    },

    /**
     * 退出登录
     */
    logout() {
      this.$confirm(this.$t('logoutTip'), this.$t('tip'), {
        confirmButtonText: this.$t('submitText'),
        cancelButtonText: this.$t('cancelText'),
        type: 'warning'
      }).then(() => {
        this.$store.dispatch('LogOut').then(() => {
          resetRouter();
          this.$router.push({ path: '/login' });
        });
      });
    },

    showEsop() {
      if (this.isGetEsopByPlm) {
        this.handlePlmGetEsop();
      } else {
        if (!this.returnObject.esopUrl || this.returnObject.esopUrl == null) {
          this.$message({
            type: 'warning',
            message: '该工序未选择ESOP附件，请在工艺路线中进行设置！'
          });
          return;
        }
        let arr = this.returnObject.esopUrl.split('.');
        let suffix = arr[arr.length - 1];
        if (suffix == 'png' || suffix == 'jpeg' || suffix == 'jpg') {
          this.esopType = 'img';
        } else if (suffix == 'pdf') {
          this.esopType = 'pdf';
          this.downLoadEsop(this.returnObject.esopUrl);
        }
        this.showEsopDialog = true;
      }
    },
    handlePlmGetEsop() {
      this.sessionid = localStorage.getItem('plmSessionId');
      if (!this.sessionid) {
        getPlmSessionId()
          .then((res) => {
            let data = res.data.data || {};
            this.sessionid = data.sessionid;
            localStorage.setItem('plmSessionId', this.sessionid);
            this.getPlmEsopFile();
          })
          .catch((error) => {
            localStorage.removeItem('plmSessionId');
          });
      } else {
        this.getPlmEsopFile();
      }
    },
    getPlmEsopFile() {
      let params = {
        sessionid: this.sessionid,
        partNo: this.returnObject.partNo
      };
      getPlmEsopId(params)
        .then((res) => {
          let data = this._get(res, 'data.data', {});
          let docid = '';
          this._forEach(data, (item) => {
            if (item.docname.includes('组立作业指书')) {
              docid = item.docid;
            }
          });
          this.handleDownLoad(docid);
        })
        .catch((error) => {
          localStorage.removeItem('plmSessionId');
        });
    },
    handleDownLoad(docid) {
      if (docid) {
        getPlmEsopUrl({
          sessionid: this.sessionid,
          docid: docid,
          downact: 'view'
        }).then((res) => {
          let data = res.data.data;
          let url = data.downloadsrcurl;
          // let url = data.downloadsrcurl.replace('http://192.168.8.221:9180', 'http://116.236.125.2:9180');
          window.open(url, 'PDF', 'width:50%;height:50%;top:100;left:100;');
        });
      }
    },
    downLoadEsop(esopUrl) {
      this.loading = true;
      downLoad({ link: esopUrl }).then(
        (res) => {
          // var blob = new Blob([res.data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
          let fileURL = null;
          var blob = new Blob([res.data], { type: 'application/pdf' });
          if (window.createObjectURL != undefined) {
            // basic
            fileURL = window.createObjectURL(blob);
          } else if (window.webkitURL != undefined) {
            // webkit or chrome
            try {
              fileURL = window.webkitURL.createObjectURL(blob);
            } catch (error) {
              console.log(error);
            }
          } else if (window.URL != undefined) {
            // mozilla(firefox)
            try {
              fileURL = window.URL.createObjectURL(blob);
            } catch (error) {
              console.log(error);
            }
          }
          // this.pdfUrl = '/pdf/web/viewer.html?file=' + encodeURIComponent(fileURL);
          this.loading = false;
          window.open(`/pdf/web/viewer.html?file=${encodeURIComponent(fileURL)}`, 'PDF', 'width:50%;height:50%;top:100;left:100;');
        },
        (error) => {}
      );
    },
    /**
     * 包装称重并封箱
     */
    packWeightSave() {
      let reg = /^((0{1}\.\d{1,3})|([0-9]\d*\.{1}\d{1,3})|([0-9]+\d*))$/g;
      if (this.packWeightInfo.weight && !reg.test(this.packWeightInfo.weight)) {
        this.$message({
          type: 'warning',
          message: '称重重量只能填数字，不能小于0且保留三位小数！'
        });
        selectInput('weight');
        return;
      }
      if (Number(this.packWeightInfo.weight) > Number(this.packWeightInfo.weightUpper)) {
        this.$message({
          type: 'warning',
          message: '称重重量不能大于最大重量！'
        });
        selectInput('weight');
        return;
      }
      if (Number(this.packWeightInfo.weight) < Number(this.packWeightInfo.weightLower)) {
        this.$message({
          type: 'warning',
          message: '称重重量不能小于最小重量！'
        });
        selectInput('weight');
        return;
      }
      this.returnObject.weight = this.packWeightInfo.weight;
      if (this.isAutomatic) {
        this.httpRequestCommon(this.httpRequestParams.requestList, this.httpRequestParams.count, this.httpRequestParams.currentRequest);
        this.showPackWeightDialog = false;
        this.packWeightInfo.weight = '';
      } else {
        this.httpRequest(this.commonDataList, 0);
        this.showPackWeightDialog = false;
        this.packWeightInfo.weight = '';
        showSuccessLog('操作成功！');
      }
    },
    packWeightClose(done) {
      this.packWeightInfo.weight = '';
      this.returnObject.weight = '';
      done();
    },
    beforeRequestSubmit() {
      console.log(this.beforeRequestData);
      for (let i = 0; i < this.beforeRequestData.length; i++) {
        if (this.beforeRequestData[i].isReqired && !this.returnObject[this.beforeRequestData[i].code]) {
          this.$message.warning(`请输入${this.beforeRequestData[i].name}`);
          return;
        }
      }
      this.returnObject['eventResult'] = 'FAIL';
      this.httpRequest(this.httpRequestParams.requestList, this.httpRequestParams.count);
      this.showBeforeRequestDialog = false;
      this._forEach(this.beforeRequestData, (item) => {
        this.returnObject[item.code] = '';
        this.returnObject['eventResult'] = '';
      });
    },
    /**
     * 打开设备登记模态框
     */
    showEquipmentRegister() {
      this.showEquipmentRegisterDialog = true;
      this.$nextTick(() => {
        focusInput('equipmentCode');
      });
      this.getEquipmentList();
    },
    /**
     * 获取已登记的设备
     */
    getEquipmentList() {
      getOperationTool(this.returnObject.workorderStationId, 1, 'EQUIPMENT_LEDGER').then(
        (res) => {
          this.equipmentList = this._get(res, 'data.data', []);
        },
        (error) => {
          this.equipmentList = [];
        }
      );
    },
    /**
     * 登记设备
     */
    registerEquipmentInfo() {
      if (!this.equipmentForm.equipmentCode) {
        this.$message({
          type: 'warning',
          message: '请输入设备编码！'
        });
        return;
      }
      bindingEquipment({ toolType: 'EQUIPMENT_LEDGER', toolCode: this.equipmentForm.equipmentCode, workorderStationId: this.returnObject.workorderStationId }).then(
        (res) => {
          this.getEquipmentList();
          this.$message({
            type: 'success',
            message: res.data.msg
          });
          this.equipmentForm.equipmentCode = '';
          focusInput('equipmentCode');
        },
        (error) => {
          selectInput('equipmentCode');
        }
      );
    },
    /**
     * 设备登记解绑
     */
    unbingingEquipment(row) {
      unbindingTool({ id: row.id }).then((res) => {
        this.getEquipmentList();
        this.$message({
          type: 'success',
          message: res.data.msg
        });
      });
    },
    /**
     * 关闭设备登记模态框
     */
    equipmentDialogClose() {
      this.$refs.equipmentForm.resetFields();
      this.equipmentForm.toolCode = '';
      this.equipmentList = [];
      this.showEquipmentRegisterDialog = false;
    },
    /**
     * 打开工装治具模态框
     */
    showToolRegister() {
      this.showToolRegisterDialog = true;
      this.$nextTick(() => {
        focusInput('toolCode');
      });
      this.getToolList();
    },
    /**
     * 获取工装治具列表
     */
    getToolList() {
      getOperationTool(this.returnObject.workorderStationId, 1, 'TOOLING_FIXTURE').then(
        (res) => {
          this.toolList = this._get(res, 'data.data', []);
        },
        (error) => {
          this.toolList = [];
        }
      );
    },
    /**
     * 工装治具登记
     */
    registerToolInfo() {
      if (!this.toolForm.toolCode) {
        this.$message({
          type: 'warning',
          message: '请输入工装治具编码！'
        });
        return;
      }
      bindingTool({ toolType: 'TOOLING_FIXTURE', toolCode: this.toolForm.toolCode, workorderStationId: this.returnObject.workorderStationId }).then(
        (res) => {
          this.getToolList();
          this.$message({
            type: 'success',
            message: res.data.msg
          });
          this.toolForm.toolCode = '';
          focusInput('toolCode');
        },
        (error) => {
          selectInput('toolCode');
        }
      );
    },
    /**
     * 工装治具解绑
     */
    unbingingTool(row) {
      unbindingTool({ id: row.id }).then((res) => {
        this.getToolList();
        this.$message({
          type: 'success',
          message: res.data.msg
        });
      });
    },
    /**
     * 工装治具登记模态框关闭
     */
    toolDialogClose() {
      this.$refs.toolForm.resetFields();
      this.toolForm.toolCode = '';
      this.toolList = [];
      this.showToolRegisterDialog = false;
    },
    /**
     * 打开辅料登记模态框
     */
    showAccessoriesRegister() {
      this.showAccessoriesRegisterDialog = true;
      this.$nextTick(() => {
        focusInput('accessoriesCode');
      });
      setTimeout(() => {
        this.accessoriesForm.accessoriesType = 'GLUE_BARCODE';
        this.getAccessoriesList();
      }, 300);
    },
    /**
     * 查询已登记辅料信息
     */
    getAccessoriesList() {
      getOperationTool(this.returnObject.workorderStationId, 1, this.accessoriesForm.accessoriesType).then(
        (res) => {
          this.accessoriesList = this._get(res, 'data.data', []);
          const column = this.findObject(this.accessoriesListOption.column, 'partIndirectStatus');
          column.dicData = [
            { label: '已报废', value: 0 },
            { label: '正常', value: 1 },
            { label: '解冻中', value: 2 },
            { label: '解冻完成', value: 3 },
            { label: '搅拌中', value: 4 },
            { label: '搅拌完成', value: 5 },
            { label: '使用中', value: 6 },
            { label: '冷藏中', value: 7 },
            { label: '已解绑', value: 8 },
            { label: '已过期', value: 9 }
          ];
        },
        (error) => {
          this.accessoriesList = [];
        }
      );
    },
    /**
     * 登记辅料信息
     */
    registerAccessoriesInfo() {
      if (!this.accessoriesForm.accessoriesType) {
        this.$message({
          type: 'warning',
          message: '请选择辅料类型！'
        });
        return;
      }
      if (!this.accessoriesForm.accessoriesCode) {
        this.$message({
          type: 'warning',
          message: '请输入辅料条码！'
        });
        return;
      }
      let type = this.accessoriesForm.accessoriesType;
      let code = this.accessoriesForm.accessoriesCode;
      let params = {
        toolType: type,
        toolCode: code,
        workorderStationId: this.returnObject.workorderStationId
      };
      if (this.accessoriesForm.accessoriesType === 'GLUE_BARCODE') {
        params['routeCode'] = this.returnObject.workStationCode;
      }
      bindingAccessories(params).then(
        (res) => {
          this.$message({
            type: 'success',
            message: res.data.msg
          });
          this.getAccessoriesList();
          this.accessoriesForm.accessoriesCode = '';
          focusInput('accessoriesCode');
          setTimeout(() => {
            this.getBindAccessoriesList();
          }, 1000);
        },
        (error) => {
          selectInput('accessoriesCode');
        }
      );
    },
    /**
     * 解绑辅料
     */
    unbindingAccessoriesInfo(row) {
      unbindingAccessories({ id: row.id }).then((res) => {
        this.$message({
          type: 'success',
          message: res.data.msg
        });
        this.getAccessoriesList();
        setTimeout(() => {
          this.getBindAccessoriesList();
        }, 1000);
      });
    },
    /**
     * 关闭辅料登记模态框
     */
    accessoriesDialogClose() {
      this.$refs.accessoriesForm.resetFields();
      this.accessoriesForm.accessoriesCode = '';
      this.accessoriesList = [];
      this.showAccessoriesRegisterDialog = false;
    },
    /**
     * 获取绑定的所有辅料
     */
    getBindAccessoriesList() {
      this.expiredQuantity = 0;
      getAccessoriesList(this.returnObject.workorderStationId).then((res) => {
        let accessoriesList = this._get(res, 'data.data', []);
        this.$message.closeAll();
        this.isCheckExpireMes = false;
        this._forEach(accessoriesList, (item, index) => {
          if (item.maxUsageTime && item.maxUsageTime != null) {
            let nowTime = new Date().getTime();
            let endTime = new Date(this.$moment(item.createTime).add(Number(item.maxUsageTime), 'hours')).getTime();
            let time = Number(endTime) - Number(nowTime);
            const uniqueKey = item.barCode;
            const timeOutEndSet = new Map();
            if (time > 0) {
              this.createTimeout(
                time,
                () => {
                  this.expiredQuantity = Number(this.expiredQuantity) + 1;
                  this.$message({
                    showClose: true,
                    type: 'error',
                    message: `您登记的辅料${item.barCode}已到最长使用时间限制，请及时更换辅料！`,
                    duration: 0
                  });
                  if (item.type === 'GLUE_BARCODE') {
                    this.isCheckExpireMes = true;
                  }
                },
                uniqueKey,
                timeOutEndSet
              );
            } else {
              this.expiredQuantity = Number(this.expiredQuantity) + 1;
              this.$message({
                showClose: true,
                type: 'error',
                message: `您登记的辅料${item.barCode}已到最长使用时间限制，请及时更换辅料！`,
                duration: 0
              });
              if (item.type === 'GLUE_BARCODE') {
                this.isCheckExpireMes = true;
              }
            }
            let expirationTime = new Date(this.$moment(item.productionDate).add(Number(item.expirationDays), 'days')).getTime();
            let delayTime = Number(expirationTime) - Number(nowTime);
            const uniqueKeyOne = item.barCode + index;
            const timeOutEndSetOne = new Map();
            if (delayTime > 0) {
              this.createTimeout(
                delayTime,
                () => {
                  if (item.type === 'GLUE_BARCODE') {
                    this.isCheckExpireMes = true;
                  }
                },
                uniqueKeyOne,
                timeOutEndSetOne
              );
            } else {
              if (item.type === 'GLUE_BARCODE') {
                this.isCheckExpireMes = true;
              }
            }
          }
        });
      });
    },
    createTimeout(timeGap, callback, uniqueKey, map) {
      const MAXGap = 1000 * 60 * 60 * 24 * 24;
      if (timeGap > MAXGap) {
        const timeouId = setTimeout(
          async (timeGap, uniqueKey, map) => {
            this.createTimeout(timeGap, callback, uniqueKey, map);
          },
          MAXGap,
          timeGap - MAXGap,
          uniqueKey,
          map
        );
        map.set(uniqueKey, timeouId);
      } else {
        const timeouId = setTimeout(
          async (uniqueKey, map) => {
            this.delTimeOut(map, uniqueKey);
            await callback();
          },
          timeGap,
          uniqueKey,
          map
        );
        map.set(uniqueKey, timeouId);
      }
    },
    delTimeOut(map, uniqueKey) {
      const tiemout = map.get(uniqueKey);
      if (tiemout) {
        clearTimeout(tiemout);
      }
      map.delete(uniqueKey);
    },
    /**
     * 展示功能箱中的小功能
     */
    showFunctionBoxItem() {
      this.isShowFunctionBox = !this.isShowFunctionBox;
      if (this.isShowFunctionBox) {
        $('.functionBox').css('height', '320px');
      } else {
        $('.functionBox').css('height', '0');
      }
    },
    beforeUpload(file) {
      if (file.type != 'image/png' && file.type != 'image/jpeg') {
        this.$message({
          type: 'warning',
          message: '请上传正确的文件类型！'
        });
        return false;
      }
      if (Number(file.size / 1024) > 150) {
        this.$message({
          type: 'warning',
          message: '上传的文件大小超出限制！'
        });
        return false;
      }
    },
    handlePreview(file) {
      let url;
      if (file.response) {
        url = this._get(file, 'response.data.link', '');
      } else {
        url = file.url;
      }
      this.$ImagePreview([{ url: url }], 0, {
        closeOnClickModal: false
      });
    },
    pictureUploadSuccess(res) {
      this.fileList.push({
        attachmentId: res.data.attachId,
        link: res.data.link,
        attachmentName: res.data.originalName
      });
      this.returnObject['attachmentUrls'] = JSON.stringify(this.fileList);
    },
    removeFile(file) {
      this._forEach(this.fileList, (item, index) => {
        if (item.link === file.response.data.link) {
          this.fileList.splice(index, 1);
        }
      });
      this.returnObject['attachmentUrls'] = JSON.stringify(this.fileList);
    },
    failureRegisterDialogClose() {
      this.$refs.failureRegisterForm.resetFields();
      this.failureNameList = [];
      this.failureCodeList = [];
      this.failureRegisterList = [];
    },
    handleFailureNameDelete(items) {
      this.failureInfoDic = this.failureInfoDic.filter((item) => {
        if (items.includes(item.code)) {
          return item;
        }
      });
    },
    showFailureRegister() {
      this.showFailureRegisterDialog = true;
      console.log(this.returnObject, 'this.returnObject');
      this.$nextTick(() => {
        focusInput('productSequenceNumber');
      });
      const userObj = JSON.parse(localStorage.getItem('saber-userInfo') || '{}');
      this.failureRegisterForm.registryByName = userObj.content.user_name;
      this.failureRegisterForm.registryBy = userObj.content.user_id;

      this.failureRegisterForm.workOrderNo = this.returnObject.workOrderNo;
      this.failureRegisterForm.workOrderId = this.returnObject.workOrderId;
      this.failureRegisterForm.productPartId = this.returnObject.productPartId;
      this.failureRegisterForm.productPartNo = this.returnObject.productPartNo;
      this.failureRegisterForm.productPartName = this.returnObject.productPartName;
      this.failureRegisterForm.productPartModel = this.returnObject.productPartModel;
      this.failureRegisterForm.fromRouteName = this.returnObject.routeName;
      this.failureRegisterForm.routeStationId = this.returnObject.routeStationId;
      this.failureRegisterForm.lineName = this.returnObject.lineName;
      this.failureRegisterForm.lineId = this.returnObject.lineId;
      this.failureRegisterForm.stationName = this.returnObject.stationName;
      this.failureRegisterForm.stationId = this.returnObject.stationId;
      this.failureRegisterForm.workshopId = this.returnObject.workshopId;
      this.failureRegisterForm.workshopName = this.returnObject.workshopName;
      this.failureInfoForm = [];
      this.failureInfoDic = [];
    },
    goFailureCode() {
      getSnProductInfo(this.failureRegisterForm.productSequenceNumber).then((res) => {
        let data = res.data.data || {};
        if (this.failureRegisterForm.workOrderNo && this.failureRegisterForm.workOrderId !== data.workOrderId) {
          this.$message.warning('该产品序列号不属于该工单，请检查后再操作！');
          this.failureRegisterForm.productSequenceNumber = '';
        } else {
          this.failureRegisterForm.productPartNo = data.productPartNo;
          this.failureRegisterForm.productPartName = data.productPartName;
          this.failureRegisterForm.productPartModel = data.productPartModel;
          this.failureRegisterForm.productPartId = data.productPartId;
          this.failureRegisterForm.productId = data.id;
          this.$message({
            type: 'success',
            message: res.data.msg
          });
        }
      });
    },
    delFailureRegister(index) {
      this.failureRegisterList.splice(index, 1);
    },
    getFailureInfo() {
      getFailureInfoByCode({ dictType: 'BAD_PHENOMENON', code: this.failureRegisterForm.failureCode }).then(
        (res) => {
          let data = this._get(res, 'data.data', {});
          this.failureInfoDic = this._uniqWith([...this.failureInfoDic, ...[data]], (arrVal, othVal) => {
            return arrVal.id === othVal.id;
          });
          this.failureInfoForm = this.failureInfoDic.map((item) => item.code);
          this.failureRegisterForm.failureCode = '';
          focusInput('failureCode');
          this.$message({
            type: 'success',
            message: res.data.msg
          });
        },
        (error) => {
          selectInput('failureCode');
        }
      );
    },
    handleClear() {
      this.failureInfoDic = [];
      this.failureInfoForm = [];
      this.failureRegisterForm.productSequenceNumber = '';
      this.failureRegisterForm.quantity = undefined;
      this.failureRegisterForm.remark = '';
    },
    failureRegister() {
      if (this.failureInfoForm.length <= 0) {
        this.$message.error('不良现象不能为空！');
        return;
      }
      if (!this.failureRegisterForm.quantity) {
        this.$message.error('不良数不能为空！');
        return;
      }

      let repaireRegisterDetailDTOList = this.failureInfoDic.map((item) => {
        return {
          badPhenomenonId: item.id,
          badPhenomenonCode: item.code,
          badPhenomenonName: item.name
        };
      });
      let params = {
        workOrderId: this.failureRegisterForm.workOrderId,
        workOrderNo: this.failureRegisterForm.workOrderNo,
        productPartId: this.failureRegisterForm.productPartId,
        productPartNo: this.failureRegisterForm.productPartNo,
        productPartName: this.failureRegisterForm.productPartName,
        productPartModel: this.failureRegisterForm.productPartModel,
        productId: this.failureRegisterForm.productId,
        productSn: this.failureRegisterForm.productSequenceNumber,
        inputSource: 'MANUAL',
        badQuantity: this.failureRegisterForm.quantity,
        workshopId: this.failureRegisterForm.workshopId,
        workshopName: this.failureRegisterForm.workshopName,
        lineId: this.failureRegisterForm.lineId,
        lineName: this.failureRegisterForm.lineName,
        routeId: this.failureRegisterForm.routeStationId,
        routeName: this.failureRegisterForm.fromRouteName,
        stationId: this.failureRegisterForm.stationId,
        stationName: this.failureRegisterForm.stationName,
        registerUserName: this.failureRegisterForm.registryByName,
        registerUserId: this.failureRegisterForm.registryBy,
        registerDescription: this.failureRegisterForm.remark,
        repaireRegisterDetailDTOList
      };
      saveFailureInfo(params).then((res) => {
        this.$message({
          type: 'success',
          message: res.data.msg
        });
        this.handleClear();
      });
    },
    // failureRegister() {
    //   if (this.failureRegisterList.length === 0) {
    //     this.$message.warning('请先录入不良数据！');
    //     return;
    //   }
    //   this._forEach(this.failureRegisterList, (item) => {
    //     delete item.failureName;
    //   });
    //   saveFailureInfo(this.failureRegisterList).then((res) => {
    //     this.showFailureRegisterDialog = false;
    //     this.$message.success(res.data.msg);
    //   });
    // },
    submitSequenceNumber() {
      this.returnObject['mixPackSequenceNumber'] = this.mixPackForm.mixPackSequenceNumber;
      this.returnObject.isSupportMixPack = true;
      this.httpRequest(this.mixPackHttpRequestList, 0);
    },
    submitProductInfo() {
      this.showMixPackDialog = false;
      if (!Array.isArray(this.returnObject[this.mixPackField])) {
        this.returnObject[this.mixPackField] = new Array();
      }
      this.returnObject[this.mixPackField] = this.mixPackProductList;
      let component = this._find(this.customForms, { field: this.mixPackField });
      this.setTableValue(component, this.returnObject[this.mixPackField]);
    },
    delProductInfo(index) {
      this.mixPackProductList.splice(index, 1);
    },
    mixPackDialogClose() {
      this.$refs.mixPackForm.resetFields();
      this.mixPackForm = {};
      this.mixPackProductList = [];
    },
    tableRowClassName({ row, rowIndex }) {
      if (row.workOrderNo != this.returnObject.workOrderNo) {
        return 'row-red';
      }
      return '';
    },
    showWorkOrderFeeding() {
      this.showWorkOrderFeedingDialog = true;
      this.$nextTick(() => {
        focusInput('packNo');
      });
      this.workOrderFeedingForm.workOrderNo = this.returnObject.workOrderNo;
      this.workOrderFeedingForm.lineName = this.returnObject.lineName;
      this.workOrderFeedingForm.sectionName = this.returnObject.workSectionName;
      getLineDetail(this.returnObject.lineId).then((res) => {
        this.workOrderFeedingForm.lineCode = this._get(res, 'data.data.code', '');
      });
      this.getWorkOrderFeedingList();
    },
    getWorkOrderFeedingList() {
      let paramMap = {
        workOrderId: this.returnObject.workOrderId,
        lineId: this.returnObject.lineId,
        workSectionId: this.returnObject.workSectionId
      };
      if (!paramMap.lineId) {
        delete paramMap.lineId;
      }
      if (!paramMap.workSectionId) {
        delete paramMap.workSectionId;
      }
      getFeedingList(paramMap).then((res) => {
        this.feedingInfoData = this._get(res, 'data.data', []);
        this.getNoKeyFeedingList();
      });
    },
    getNoKeyFeedingList() {
      let params = {
        workOrderId: this.returnObject.workOrderId,
        lineCode: this.workOrderFeedingForm.lineCode,
        workSectionId: this.returnObject.workSectionId
      };
      if (!params.lineCode) {
        delete params.lineCode;
      }
      if (!params.workSectionId) {
        delete params.workSectionId;
      }
      getNoKeyFeedingData(params).then((res) => {
        this.feedingDetailInfoData = this._get(res, 'data.data', []);
      });
    },
    workOrderFeedingSubmit(value) {
      if (!this.workOrderFeedingForm.packNo) {
        this.$message.warning('请请扫描原材料包装条码！');
        return;
      }
      setTimeout(() => {
        if (value != this.workOrderFeedingForm.packNo) {
          return;
        } else {
          let params = {
            workOrderNo: this.returnObject.workOrderNo,
            lineCode: this.workOrderFeedingForm.lineCode,
            packNo: this.workOrderFeedingForm.packNo
          };
          checkPackNo(params).then(
            (res) => {
              let data = res.data.data;
              if (!data) {
                this.$confirm('该包物料与之前物料上次批次不同，是否确认继续？', '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                  this.feeding();
                });
              } else {
                this.feeding();
              }
            },
            (error) => {
              selectInput('packNo');
            }
          );
        }
      }, 500);
    },
    feeding() {
      let params = {
        workOrderNo: this.returnObject.workOrderNo,
        partNo: this.returnObject.partNo,
        workSectionCode: this.returnObject.workSectionCode,
        lineCode: this.workOrderFeedingForm.lineCode,
        packNo: this.workOrderFeedingForm.packNo
      };
      workOrderfeeding(params).then(
        (res) => {
          this.$message.success(res.data.msg);
          this.workOrderFeedingForm.packNo = '';
          focusInput('packNo');
          this.getWorkOrderFeedingList();
        },
        (error) => {
          selectInput('packNo');
        }
      );
    },
    workOrderFeedingDialogClose() {
      this.$refs.workOrderFeedingForm.resetFields();
      this.workOrderFeedingForm = {};
      this.checkWorkOrderFeeding();
    },
    showToolOperate() {
      this.showToolOperateDialog = true;
      this.$nextTick(() => {
        focusInput('machineCode');
      });
      this.toolOperateForm.workOrderId = this.returnObject.workOrderId;
      this.toolOperateForm.workOrderNo = this.returnObject.workOrderNo;
      this.toolOperateForm.partId = this.returnObject.partId;
      this.toolOperateForm.partNo = this.returnObject.partNo;
      this.toolOperateForm.partName = this.returnObject.partName;
      this.toolOperateForm.planQuantity = this.returnObject.planQuantity;
      this.toolOperateForm.bomId = this.returnObject.bomId;
      getAlreadyOnMachine({ workOrderId: this.toolOperateForm.workOrderId }).then((res) => {
        let toolOperateInfoData = this._get(res, 'data.data', []);
        this.toolOperateInfoData = this._map(toolOperateInfoData, (item) => {
          return {
            onlyShow: true,
            toolType: item.subType,
            toolCode: item.toolCode,
            equipmentSpecification: item.specification,
            maxUsage: item.maxUsage,
            surplusUsage: item.quantityAvailable
          };
        });
      });
      getToolTypeList().then((res) => {
        let list = this._get(res, 'data.data', []);
        let toolType1 = this.findObject(this.toolOperateOption.column, 'toolType');
        toolType1.dicData = this._map(list, (item) => {
          return {
            label: item.dictValue,
            value: item.dictKey
          };
        });
        this.toolTypeList = toolType1.dicData;
        let toolType2 = this.findObject(this.toolOperateInfoOption.column, 'toolType');
        toolType2.dicData = this.toolTypeList;
      });
    },
    verifyMachineCode() {
      if (!this.toolOperateForm.machineCode) {
        this.$message.error('请扫描设备编码！');
        return;
      }
      let paramMap = {
        code: this.toolOperateForm.machineCode,
        equipmentType: 'MACHINE'
      };
      toolRelation(paramMap).then(
        (res) => {
          let data = this._get(res, 'data.data', {});
          if (!data) {
            this.$message.warning('设备编码不存在！');
            selectInput('machineCode');
            return;
          }
          this.toolOperateForm.machineId = data.id;
          this.toolOperateForm.machineCode = data.code;
          if (this.toolOperateForm.machineId && this.toolOperateForm.machineCode) {
            this.toolIsUseRecord = true;
          }
          this.toolOperateForm.machineName = data.name;
          this.toolOperateForm.lineId = data.lineId;
          this.toolOperateForm.lineName = data.lineName;
          this.toolOperateForm.machineSpecification = data.specification;
          this.toolsType = data.toolType || [];
          if (this.returnObject.lineId != data.lineId) {
            this.$confirm('当前生产产线与设备所在产线不一致，请确认是否继续工具上机？', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            })
              .then(() => {})
              .catch(() => {
                this.toolOperateForm.machineCode = '';
              });
          }
        },
        (error) => {
          selectInput('machineCode');
        }
      );
    },
    changeToolType() {
      if (!this.toolOperateForm.machineCode) {
        this.$message.error('请扫描设备编码！');
        setTimeout(() => {
          this.toolOperateForm.toolType = '';
        });
        return;
      }
      let numberCavities = this.findObject(this.toolOperateOption.column, 'numberCavities');
      if (this.toolOperateForm.toolType === 'KNIFE_MODE') {
        numberCavities.display = true;
      } else {
        numberCavities.display = false;
      }
      if (this.toolOperateForm.toolType) {
        let toolName = '';
        this.toolTypeList.forEach((item) => {
          if (item.value === this.toolOperateForm.toolType) {
            toolName = item.label;
          }
        });
        if (!this.toolsType.includes(this.toolOperateForm.toolType)) {
          this.$confirm(`当前设备未维护${toolName}，是否继续上机？`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
            .then(() => {})
            .catch(() => {
              this.toolOperateForm.toolType = '';
            });
        }
      }
    },
    //解析刀模和网版编码
    codeAnalysis(str) {
      if (str.includes('#') && (str.includes(':') || str.includes('：'))) {
        let items = str.split('#');
        let res = items[0].split('：')[1] || items[0].split(':')[1] || str;
        return res;
      } else {
        return str;
      }
    },
    verifyTool() {
      if (!this.toolOperateForm.toolType) {
        this.$message.error('请选择工具类型！');
        return;
      }

      if (!this.toolOperateForm.toolCode) {
        this.$message.error('请输入工具编码！');
        return;
      }
      clearTimeout(this.timerId);
      this.timerId = setTimeout(() => {
        let params = {};
        let url;
        if (this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS') {
          if (!this.toolOperateForm.workOrderId) {
            this.$message.error('请选择工单号！');
            return;
          }
          console.log(this.toolOperateForm.toolCode, 4444);
          this.toolOperateForm.toolCode = this.codeAnalysis(this.toolOperateForm.toolCode);
          console.log(this.toolOperateForm.toolCode, 5555);
          params = {
            bomId: this.toolOperateForm.bomId,
            code: this.toolOperateForm.toolCode,
            partMasterId: this.toolOperateForm.partId,
            workOrderId: this.toolOperateForm.workOrderId,
            subType: this.toolOperateForm.toolType,
            transType: 4
          };
          url = '/api/mes-product/ems-equipment-usage/check-tool';
        } else {
          params = {
            code: this.toolOperateForm.toolCode,
            subType: this.toolOperateForm.toolType,
            partMasterId: this.toolOperateForm.partId,
            workOrderId: this.toolOperateForm.workOrderId,
            transType: 4
          };
          url = '/api/mes-product/ems-equipment-usage/check';
        }
        let statusObj = {
          0: '该工具已禁用，不可使用',
          1: '该工具未领用，请领用后操作',
          2: '该工具已上机，请勿重复操作',
          // 3: '该工具已停机，不可使用',
          5: '该工具已报废，不可使用'
        };
        request({
          url: encodeURI(url),
          method: 'post',
          data: params
        }).then(
          (res) => {
            let data = this._get(res, 'data.data', {});
            if (data === null) {
              this.$message.error('未找到该工具编码，请重新输入！');
              selectInput('toolCode');
            } else {
              let status = this._get(data, 'status', 0);
              if (statusObj[status]) {
                this.$message.error(statusObj[status]);
                selectInput('toolCode');
                return;
              }
              let obj = this._find(this._cloneDeep(this.toolOperateInfoData), {
                equipmentCode: this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? data.toolCode : data.code,
                toolType: this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? data.equipmentType : data.subType
              });
              this.toolOperateForm.numberCavities = data.numberCavities;
              if (obj) {
                this.$message.error('请勿扫描重复的工具编码！');
                selectInput('toolCode');
                return;
              }
              this.openCommonModal(data);
            }
          },
          (error) => {
            selectInput('toolCode');
          }
        );
      }, 600);
    },
    openCommonModal(form) {
      let toolTypeObj = {
        STEELMESH: '钢网',
        SCRAPER: '刮刀',
        KNIFE: '刀具',
        KNIFE_MODE: '刀模',
        MESH_PANELS: '网版'
      };
      form.toolType = form.toolType || form.subType || form.equipmentType;
      form.preWorkOrderUsedTimes = form.preWorkOrderUsedTimes || 0;
      form.planUsageTimes = form.planUsageTimes || form.thisExpectedUsedTimes || 0;
      form.equipmentPartStr = form.equipmentPartStr || form.partNo || String((form.equipmentPartList || []).map((item) => item.partName));
      form.equipmentCode = this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? form.toolCode : form.code;
      form.equipmentName = this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? form.toolName : form.name;
      form.toolTypeName = toolTypeObj[form.toolType];
      form.remainingUsedTimes = Number(form.maxUsage) - Number(form.timesUsed || 0);
      form.remainingUsedTimesStr = form.remainingUsedTimes + '（' + (Math.round((form.remainingUsedTimes / Number(form.maxUsage)) * 100) / 100) * 100 + '%' + ')';
      let toolsObjColumn = {
        STEELMESH: [
          {
            label: '工具类型',
            prop: 'toolTypeName',
            disabled: true
          },
          {
            label: '编码',
            prop: 'equipmentCode',
            disabled: true
          },
          {
            label: '名称',
            prop: 'equipmentName',
            disabled: true
          },
          {
            label: '规格',
            prop: 'specification',
            disabled: true
          },
          {
            label: '适用产品',
            prop: 'equipmentPartStr',
            disabled: true
          },
          {
            label: 'B/T面',
            prop: 'side',
            disabled: true
          },
          {
            label: '环保类型',
            prop: 'epType',
            disabled: true
          },
          {
            label: '产品工艺',
            prop: 'productProcess',
            disabled: true
          },
          {
            label: '最大使用次数',
            prop: 'maxUsage',
            disabled: true
          },
          {
            label: '前工单使用次数',
            prop: 'preWorkOrderUsedTimes',
            type: 'number'
          },
          {
            label: '已使用次数',
            prop: 'timesUsed',
            disabled: true
          },
          {
            label: '剩余使用次数',
            prop: 'remainingUsedTimesStr',
            disabled: true,
            class: Number(form.planUsageTimes) > Number(form.remainingUsedTimes) ? 'fontRed' : ''
          },
          {
            label: '本次预计使用',
            prop: 'planUsageTimes',
            disabled: true,
            class: Number(form.planUsageTimes) > Number(form.remainingUsedTimes) ? 'fontRed' : ''
          },
          {
            label: '备注',
            prop: 'remark',
            disabled: true
          }
        ],
        SCRAPER: [
          {
            label: '编码',
            prop: 'equipmentCode',
            disabled: true
          },
          {
            label: '名称',
            prop: 'equipmentName',
            disabled: true
          },
          {
            label: '规格',
            prop: 'specification',
            disabled: true
          },
          {
            label: '环保类型',
            prop: 'epType',
            disabled: true
          },
          {
            label: '厚度',
            prop: 'thickness',
            disabled: true
          },
          {
            label: '倾斜角',
            prop: 'slantAngle',
            disabled: true
          },
          {
            label: '最大使用次数',
            prop: 'maxUsage',
            disabled: true
          },
          {
            label: '前工单使用次数',
            prop: 'preWorkOrderUsedTimes',
            disabled: false,
            type: 'number'
          },
          {
            label: '已使用次数',
            prop: 'timesUsed',
            disabled: true
          },
          {
            label: '剩余使用次数',
            prop: 'remainingUsedTimesStr',
            disabled: true,
            class: Number(form.planUsageTimes) > Number(form.remainingUsedTimes) ? 'fontRed' : ''
          },
          {
            label: '本次预计使用',
            prop: 'planUsageTimes',
            disabled: true,
            class: Number(form.planUsageTimes) > Number(form.remainingUsedTimes) ? 'fontRed' : ''
          },
          {
            label: '备注',
            prop: 'remark',
            disabled: true
          }
        ],
        KNIFE: [
          {
            label: '编码',
            prop: 'equipmentCode',
            disabled: true
          },
          {
            label: '名称',
            prop: 'equipmentName',
            disabled: true
          },
          {
            label: '规格',
            prop: 'specification',
            disabled: true
          },
          {
            label: '最大使用次数',
            prop: 'maxUsage',
            disabled: true
          },
          {
            label: '前工单使用次数',
            prop: 'preWorkOrderUsedTimes',
            disabled: false,
            type: 'number'
          },
          {
            label: '已使用次数',
            prop: 'timesUsed',
            disabled: true
          },
          {
            label: '剩余使用次数',
            prop: 'remainingUsedTimesStr',
            disabled: true,
            class: Number(form.planUsageTimes) > Number(form.remainingUsedTimes) ? 'fontRed' : ''
          },
          {
            label: '备注',
            prop: 'remark',
            disabled: true
          }
        ],
        KNIFE_MODE: [
          {
            label: '编码',
            prop: 'equipmentCode',
            disabled: true
          },
          {
            label: '名称',
            prop: 'equipmentName',
            disabled: true
          },
          {
            label: '规格',
            prop: 'specification',
            disabled: true
          },
          {
            label: '适用产品',
            prop: 'equipmentPartStr',
            disabled: true
          },
          {
            label: '最大使用次数',
            prop: 'maxUsage',
            disabled: true
          },
          {
            label: '前工单使用次数',
            prop: 'preWorkOrderUsedTimes',
            disabled: false,
            type: 'number'
          },
          {
            label: '已使用次数',
            prop: 'timesUsed',
            disabled: true
          },
          {
            label: '剩余使用次数',
            prop: 'remainingUsedTimesStr',
            disabled: true,
            class: Number(form.planUsageTimes) > Number(form.remainingUsedTimes) ? 'fontRed' : ''
          },
          {
            label: '本次预计使用',
            prop: 'planUsageTimes',
            disabled: true,
            class: Number(form.planUsageTimes) > Number(form.remainingUsedTimes) ? 'fontRed' : ''
          },
          {
            label: '备注',
            prop: 'remark',
            disabled: true
          }
        ],
        MESH_PANELS: [
          {
            label: '编码',
            prop: 'equipmentCode',
            disabled: true
          },
          {
            label: '名称',
            prop: 'equipmentName',
            disabled: true
          },
          {
            label: '规格',
            prop: 'specification',
            disabled: true
          },
          {
            label: '适用产品',
            prop: 'equipmentPartStr',
            disabled: true
          },
          {
            label: '最大使用次数',
            prop: 'maxUsage',
            disabled: true
          },
          {
            label: '前工单使用次数',
            prop: 'preWorkOrderUsedTimes',
            disabled: false,
            type: 'number'
          },
          {
            label: '已使用次数',
            prop: 'timesUsed',
            disabled: true
          },
          {
            label: '剩余使用次数',
            prop: 'remainingUsedTimesStr',
            disabled: true,
            class: Number(form.planUsageTimes) > Number(form.remainingUsedTimes) ? 'fontRed' : ''
          },
          {
            label: '本次预计使用',
            prop: 'planUsageTimes',
            disabled: true,
            class: Number(form.planUsageTimes) > Number(form.remainingUsedTimes) ? 'fontRed' : ''
          },
          {
            label: '备注',
            prop: 'remark',
            disabled: true
          }
        ]
      };
      this.toolDetailOption.column = toolsObjColumn[form.toolType];
      this.showToolDetailDialog = true;
      this.toolDetailForm = form;
    },
    detailStrategy() {
      this.toolOperateInfoData.push({
        ...this.toolDetailForm,
        preWorkOrderUsedTimes: this.toolDetailForm.preWorkOrderUsedTimes,
        machineId: this.toolOperateForm.machineId,
        machineCode: this.toolOperateForm.machineCode,
        machineName: this.toolOperateForm.machineName,
        machineSpecification: this.toolOperateForm.machineSpecification,
        workOrderId: this.toolOperateForm.workOrderId,
        workOrderNo: this.toolOperateForm.workOrderNo,
        equipmentId:
          this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? this.toolDetailForm.equipmentId : this.toolDetailForm.id,
        equipmentCode:
          this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? this.toolDetailForm.toolCode : this.toolDetailForm.code,
        code: this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? this.toolDetailForm.toolCode : this.toolDetailForm.code,
        toolCode: this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? this.toolDetailForm.toolCode : this.toolDetailForm.code,
        toolType:
          this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? this.toolDetailForm.equipmentType : this.toolDetailForm.subType,
        equipmentName:
          this.toolOperateForm.toolType === 'KNIFE_MODE' || this.toolOperateForm.toolType === 'MESH_PANELS' ? this.toolDetailForm.toolName : this.toolDetailForm.name,
        equipmentSpecification: this.toolDetailForm.specification,
        maxUsage: this.toolDetailForm.maxUsage,
        timesUsed: this.toolDetailForm.timesUsed,
        surplusUsage: Number(this.toolDetailForm.maxUsage) - Number(this.toolDetailForm.timesUsed || 0),
        surplusPercentage:
          (Math.round(((Number(this.toolDetailForm.maxUsage) - Number(this.toolDetailForm.timesUsed || 0)) / Number(this.toolDetailForm.maxUsage)) * 100) / 100) * 100 + '%',
        transType: 4,
        partMasterId: this.toolOperateForm.partId,
        lineId: this.toolOperateForm.lineId,
        lineName: this.toolOperateForm.lineName,
        bomId: this.toolOperateForm.bomId,
        partMasterIdList: []
      });
      this.toolOperateForm.toolCode = '';
      this.$message.success('操作成功！');
      this.showToolDetailDialog = false;
      focusInput('toolCode');
    },
    findMachineUsageRecord() {
      let paramMap = {
        equipmentCode: this.toolOperateForm.machineCode,
        workOrderId: this.toolOperateForm.workOrderId
      };
      getMachineUseRecord(paramMap).then(
        (res) => {
          let data = this._get(res, 'data.data', {});
          let equipmentList = this._map(data.equipmentVOList || [], (item) => {
            item.partMasterIdList = [];
            this._map(data.toolPartList || [], (t) => {
              if (t.toolId === item.id) {
                item.partMasterIdList = t.partMasterIdList || [];
              }
            });
            item.machineId = this.toolOperateForm.machineId;
            item.machineCode = this.toolOperateForm.machineCode;
            item.machineName = this.toolOperateForm.machineName;
            item.machineSpecification = this.toolOperateForm.machineSpecification;
            item.workOrderId = this.toolOperateForm.workOrderId;
            item.workOrderNo = this.toolOperateForm.workOrderNo;
            item.equipmentId = item.id;
            item.equipmentCode = item.code;
            item.toolCode = item.code;
            item.toolType = item.subType;
            item.equipmentName = item.name;
            item.equipmentSpecification = item.specification;
            item.surplusUsage = Number(item.maxUsage) - Number(item.timesUsed || 0);
            item.surplusPercentage = (Math.round(((Number(item.maxUsage) - Number(item.timesUsed || 0)) / Number(item.maxUsage)) * 100) / 100) * 100 + '%';
            item.transType = 4;
            item.partMasterId = this.toolOperateForm.partId;
            item.lineId = this.toolOperateForm.lineId;
            item.lineName = this.toolOperateForm.lineName;
            item.bomId = this.toolOperateForm.bomId;
            item.suitPartCheckFlag = true;
            return item;
          });
          this.toolOperateInfoData = this._uniqWith(this.toolOperateInfoData.concat(equipmentList), (cur, oth) => {
            return cur.toolCode === oth.toolCode;
          });
        },
        (error) => {
          selectInput('machineCode');
        }
      );
    },
    delToolOperateInfo(index) {
      this.toolOperateInfoData.splice(index, 1);
    },
    submitToolOperateInfo() {
      if (!this.toolOperateForm.workOrderId) {
        this.$message.error('请选择工单号！');
        return;
      }
      if (!this.toolOperateForm.machineCode) {
        this.$message.error('请扫描设备编码！');
        return;
      }
      let tableList = this._map(this.toolOperateInfoData, (item) => {
        if (!item.onlyShow) {
          return item;
        }
      }).filter((ite) => typeof ite !== 'undefined');
      if (tableList.length === 0) {
        this.$message.error('请至少扫描一个工具编码！');
        return;
      }
      for (let i = 0; i < this.toolOperateInfoData.length; i++) {
        if (this.toolOperateInfoData[i].suitPartCheckFlag && this.toolOperateInfoData[i].partMasterIdList.length > 0) {
          if (!this.toolOperateInfoData[i].partMasterIdList.includes(this.toolOperateForm.partId)) {
            this.$message.error(`工具编码${this.toolOperateInfoData[i].equipmentCode}适用产品与工单产品不匹配`);
            return;
          }
        }
      }

      let params = [];
      this._forEach(this.toolOperateInfoData, (item) => {
        if (!item.onlyShow) {
          params.push({
            toolId: item.equipmentId,
            toolCode: item.equipmentCode,
            toolName: item.equipmentName,
            toolType: item.toolType,
            toolSpecfication: item.equipmentSpecification,
            partMasterId: item.partMasterId,
            equipmentId: item.machineId,
            equipmentCode: item.machineCode,
            equipmentName: item.machineName,
            workOrderId: item.workOrderId,
            workOrderNo: item.workOrderNo,
            equipmentSpecification: item.machineSpecification,
            transType: item.transType,
            preWorkOrderUsedTimes: item.preWorkOrderUsedTimes || 0,
            lineId: item.lineId,
            lineName: item.lineName,
            bomId: item.bomId
          });
        }
      });
      submitToolList(params).then((res) => {
        this.showToolOperateDialog = false;
        this.$message.success(res.data.msg);
      });
    },
    toolOperateDialogClose() {
      this.$refs.toolOperateForm.resetFields();
      this.toolOperateForm = {};
      this.toolOperateInfoData = [];
      this.toolIsUseRecord = false;
    },
    checkWorkOrderFeeding() {
      getParamDetail({
        paramKey: 'isEnabledFeedingToolOperation'
      }).then((res) => {
        let paramValue = this._get(res, 'data.data.paramValue', 'false');
        if (paramValue === 'true') {
          checkIsFeeding(this.returnObject.workOrderNo).then((res) => {
            if (res.data.msg.includes('没有进行工单上料')) {
              if (this.noFeedingPromptNum === 0) {
                this.$confirm(res.data.msg, '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                  this.showWorkOrderFeeding();
                });
                this.noFeedingPromptNum++;
              }
            } else if (res.data.msg.includes('没有进行工具上机')) {
              this.$confirm(res.data.msg, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                this.showToolOperate();
              });
            }
          });
        }
      });
    }
  }
};
